![](/img/trans.png)
[英]Deleting a file from a sub directory of an AWS S3 bucket using asp.net
[英]Random behaviour while deleting bucket from S3
我正在編寫與Aws s3交互以執行各種操作的代碼,例如創建存儲桶、刪除存儲桶、上傳和下載文件等。 嘗試刪除存儲桶時出現問題; 拒絕訪問
目前,我正在使用Root 用戶憑據來創建和刪除存儲桶。 未啟用版本控制,並且無法在附加到此存儲桶的 AWS 控制台中看到任何存儲桶策略。
它表現出奇怪的行為; 有時在嘗試刪除空存儲桶時會出現訪問被拒絕錯誤,有時它會毫不費力地刪除。
我可以毫無困難地通過 AWs s3 控制台刪除存儲桶。 只是通過代碼,它的行為是隨機的。
可以請人解釋一下嗎? 可能是什么原因?
這是我的代碼
public string DeleteBucket(string bucketName, string S3Region)
{
string sts = "";
Chilkat.Http http = new Chilkat.Http();
// Insert your access key here:
http.AwsAccessKey = "AccessKey";
http.AwsSecretKey = "SecretKey"; //root user
http.AwsRegion = S3Region;
bool success = http.S3_DeleteBucket(bucketName);
if (success != true)
{
return sts = "{\"Status\":\"Failed\",\"Message\":\""http.lastErrorText"\"}";
}
else
{
return sts = "{\"Status\":\"Success\",\"Message\":\"Bucket deleted!\"}";
}
}
您應該檢查 HTTP 響應正文以查看來自 AWS 的錯誤消息。 例如:
http.KeepResponseBody = true;
bool success = http.S3_DeleteBucket(bucketName);
if (success != true) {
Debug.WriteLine(http.LastErrorText);
// Also examine the error response body from AWS:
Debug.WriteLine(http.LastResponseBody);
}
else {
Debug.WriteLine("Bucket created.");
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.