简体   繁体   English

从 S3 中删除存储桶时的随机行为

[英]Random behaviour while deleting bucket from S3

I am working on the code that interacts with Aws s3 to perform various operations like create bucket, Delete bucket, upload and download files and so on.我正在编写与Aws s3交互以执行各种操作的代码,例如创建存储桶、删除存储桶、上传和下载文件等。 An issue is occurring while trying to delete the bucket;尝试删除存储桶时出现问题; Access Denied拒绝访问

At present, I am using Root user credentials to create and delete the bucket.目前,我正在使用Root 用户凭据来创建和删除存储桶。 No versioning is enabled and could not see any bucket Policy in AWS Console attached to this bucket.未启用版本控制,并且无法在附加到此存储桶的 AWS 控制台中看到任何存储桶策略。

It is showing strange behaviour;它表现出奇怪的行为; sometimes gives access denied error while trying to delete the empty bucket , sometime it just gets delete effortlessly.有时在尝试删除空存储桶时会出现访问被拒绝错误,有时它会毫不费力地删除。

I am able to delete the bucket via AWs s3 console without any trouble.我可以毫无困难地通过 AWs s3 控制台删除存储桶。 It is just through the code it is behaving random.只是通过代码,它的行为是随机的。

Can please somebody explain;可以请人解释一下吗? what could be the reason?可能是什么原因?

here is my code这是我的代码

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!\"}";
    }
}

You should examine the HTTP response body to see the error message from AWS.您应该检查 HTTP 响应正文以查看来自 AWS 的错误消息。 For example:例如:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM