Skip to content

Instantly share code, notes, and snippets.

@cleberdantas
Created January 7, 2015 19:09
Show Gist options
  • Save cleberdantas/cfcfa9fecbe5a0aae6d5 to your computer and use it in GitHub Desktop.
Save cleberdantas/cfcfa9fecbe5a0aae6d5 to your computer and use it in GitHub Desktop.
Upload a image to Amazon S3
var file = Request.Files[0];
if (file.ContentLength > 0)
{
Amazon.S3.AmazonS3Client client;
using (client = new AmazonS3Client(new AmazonS3Config() { ServiceURL = "http://s3.amazonaws.com" }))
{
PutObjectRequest request = new PutObjectRequest();
request.BucketName = "bucketname";
request.CannedACL = S3CannedACL.PublicRead;
request.Key = "filename";
request.InputStream = file.InputStream;
PutObjectResponse response = client.PutObject(request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment