无法创建存储桶,将对象添加到存储桶或从存储桶中获取对象,其中包含“-”(破折号)的存储桶名称

时间:2019-06-21 13:47:08

标签: amazon-s3 .net-core atlassian-localstack

我正在尝试使用.net core将S3存储桶创建到本地堆栈中

var bucket_name =“演示桶”; var key =“ key_test”;

if (!await _s3Client.DoesS3BucketExistAsync(bucket_name))
{
 var putBucketRequest = new PutBucketRequest
 {
  BucketName = bucket_name,
  UseClientRegion = true
 };

 var response = await _s3Client.PutBucketAsync(putBucketRequest);
}

它不会创建存储桶。如果存储桶不存在,则上述if条件将返回true。

当我尝试添加对象时:

var putRequest1 = new PutObjectRequest
{
 BucketName = bucket_name,
 Key = key,
 ContentBody = "sample text hello there"
};

PutObjectResponse response1 = await s3Client.PutObjectAsync(putRequest1);

失败并显示错误

Amazon.S3.AmazonS3Exception:发出错误代码为InternalServerError和Http Status Code InternalServerError的请求时出错。服务未返回其他错误信息

0 个答案:

没有答案