Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Upload a file to S3 (asp.net)
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