Does Amazon S3 PutObject () return a value to confirm success?

About once a week, a file is downloaded when it is saved to Amazon S3 (1 \ 300). The following code works well enough to confirm that the file was saved correctly, but I cannot help but think that there is a better way. When the file does not work, an exception is not thrown, so I'm never sure where the problem is. Any suggestions for a better confirmation?

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!");
+5
source share
1 answer

According to the API documentation, it is recommended that you check the ETag value for the calculated MD5 hash of the data you sent. Obviously, they must match.

" , , MD5 , Amazon S3 Etag MD5."

http://docs.amazonwebservices.com/AmazonS3/latest/API/SOAPPutObject.html

,

+4

All Articles