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);

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: