Home > Uncategorized > Upload a file to Amazon S3 using C#

Upload a file to Amazon S3 using C#

This code example is probably online a million times, but just to include it again here;

string existingBucketName = “mybucket”;
string filePath = @”c:\users\you\desktop\file.png”;
Amazon.Util.ProfileManager.RegisterProfile(“test”, “xxxxx”,”XXXX”);
AWSCredentials credentials = new StoredProfileAWSCredentials(“test”);
IAmazonS3 s3Client = new AmazonS3Client(credentials, RegionEndpoint.EUWest1);
TransferUtility fileTransferUtility = new TransferUtility(s3Client);
var uploadRequest = new TransferUtilityUploadRequest
{

FilePath = filePath,
BucketName = existingBucketName,
CannedACL = S3CannedACL.PublicRead
};
fileTransferUtility.Upload(uploadRequest);

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a comment