Created
October 9, 2012 18:18
-
-
Save bradoyler/3860477 to your computer and use it in GitHub Desktop.
Upload a file to S3 (asp.net)
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
HttpPostedFileBase file = Request.Files[0]; | |
if (file.ContentLength > 0) // accept the file | |
{ | |
string accessKey = "XXXXXXXXXXX"; | |
string secretKey = "122334XXXXXXXXXX"; | |
AmazonS3 client; | |
using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKey, secretKey)) | |
{ | |
PutObjectRequest request = new PutObjectRequest(); | |
request.WithBucketName("yourbucket") | |
.WithCannedACL(S3CannedACL.PublicRead) | |
.WithKey("meals/test.jpg").InputStream = file.InputStream; | |
S3Response response = client.PutObject(request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment