C# ile REST API kullanarak S3'ten bir dosya almak için bazı kodlar çalışıyorum. Başkalarının benzer şeyler yaptığını gördüm ama bir sebepten dolayı 403 hatası almaya devam ediyorum. AWS SDK ile aynı şeyi yapmaya çalıştım. Net ve işe yarıyor, bu yüzden yetkilendirme başlığını oluşturduğum gibi olduğunu düşünüyorum.Amazon S3 REST API 403 hatası C#
Bu konuda herhangi bir ışık tutabilir mi lütfen?
string awsAccessId = "***";
string awsSecretKey = "***";
string bucketName = "thebucket";
string httpDate = DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss +0000\n");
string canonicalString = "GET\n"
+ "\n"
+ "\n"
+ "x-amz-date:" + httpDate + "\n"
+ "/" + bucketName + "/readme.txt";
// now encode the canonical string
Encoding ae = new UTF8Encoding();
// create a hashing object
HMACSHA1 signature = new HMACSHA1();
// secretId is the hash key
signature.Key = ae.GetBytes(awsSecretKey);
byte[] bytes = ae.GetBytes(canonicalString);
byte[] moreBytes = signature.ComputeHash(bytes);
// convert the hash byte array into a base64 encoding
string encodedCanonical = Convert.ToBase64String(moreBytes);
// Send the request
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://" + bucketName +".s3.amazonaws.com/readme.txt");
request.Headers.Add("x-amz-date", httpDate);
request.Headers.Add("Authorization", "AWS " + awsAccessId + ":" + encodedCanonical);
request.Method = "GET";
// Get the response
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine(response.StatusCode);
Console.Read();
Çalışıyorsa, sdk'yi neden kullanmıyorsunuz? –
Bir SSIS komut dosyası görevine koymayı umuyorum – MarkJ