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);
}
if (!DoesObjectExist(keyName))
throw new Exception("Failed!");
source
share