ASP.NET MVC - Uploading an image to Amazon S3

前端 未结 4 1429
甜味超标
甜味超标 2020-12-30 08:03

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

4条回答
  •  情书的邮戳
    2020-12-30 08:29

                    PurObjectRequest request = new PutObjectRequest()
                    {
                        BucketName = _bucketName,
                        CannedACL = S3CannedACL.PublicRead,
                        Key =  string.Format("folderyouwanttoplacethefile/{0}", file.FileName),
                        InputStream = file.InputStream
                    };
    
                    YourS3client.PutObject(request);
    

提交回复
热议问题