Created
January 7, 2015 19:09
-
-
Save cleberdantas/cfcfa9fecbe5a0aae6d5 to your computer and use it in GitHub Desktop.
Upload a image to Amazon S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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