Matthew H Matthew H - 10 months ago 61
ASP.NET (C#) Question

ASP.NET MVC - Uploading an image to Amazon S3

I have my image from Request.Files[0]. Now, how do I upload this image to S3? I see that in the AWS .NET API you have to specify ContentBody when putting an object which is a string. How would I get the content body of my file?

Answer Source
var file = Request.Files[0];
PutObjectRequest request = new PutObjectRequest();
request.BucketName = "mybucket"
request.ContentType = contentType;
request.Key = key;
request.InputStream = file.InputStream;