保存到Amazon S3(1\300)时,文件上传大约每周一周.以下代码可以很好地确认文件保存正确,但我不禁想到有更好的方法.当文件失败时,不会抛出任何异常,因此我无法确定问题所在.有任何更好的确认建议吗?
AmazonS3Config _s3Config = new AmazonS3Config
{
ServiceURL = "s3.amazonaws.com",
CommunicationProtocol = Protocol.HTTPS,
};
using (AmazonS3 client = AWSClientFactory.CreateAmazonS3Client("accessKey", "secretAccessKey", _s3Config))
{
PutObjectRequest request = new PutObjectRequest();
request.WithBucketName("bucketName")
.WithFilePath("filePath")
.WithKey("keyName");
request.WithServerSideEncryptionMethod(ServerSideEncryptionMethod.AES256);
PutObjectResponse response = client.PutObject(request);
// what property from the response object can I check to confirm success???
}
// the following DoesObjectExist() function uses the GetObjectMetadata() function
if (!DoesObjectExist(keyName))
throw new Exception("Failed!");
Run Code Online (Sandbox Code Playgroud)