我正在尝试使用.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的请求时出错。服务未返回其他错误信息