我在 S3 上创建了两个存储桶,分别命名为“demobucket”和“demo.bucket”。当我在“demobucket”上上传任何文件时,它工作正常。但是当我在“demo.bucket”上上传文件时,它给了我一个错误“达到最大重试次数:3”
我担心的是当存储桶名称包含句点(点)时上传文件有什么问题。
我的代码是:
public static bool UploadResumeFileToS3(string uploadAsFileName, Stream ImageStream, S3CannedACL filePermission, S3StorageClass storageType)
{
try
{
AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY);
PutObjectRequest request = new PutObjectRequest();
request.WithKey(uploadAsFileName);
request.WithInputStream(ImageStream);
request.WithBucketName("demo.bucket");
request.CannedACL = filePermission;
request.StorageClass = storageType;
client.PutObject(request);
client.Dispose();
}
catch
{
return false;
}
return true;
}