Amazon S3 File Upload Api C

Posted on
Active1 year, 3 months ago

‘MethodNotAllowed’ error up if the resource you are trying to access does not have the relevant permissions. It could be because of incorrect bucket name. Well here are the instruction that you have to follow to get a fully working demo program. 1-Download and install the Amazon web services SDK for.NET which you can find in (because I have visual studio 2010 I choose to install the 3.5.NET SDK. 2- open visual studio.

I'm using the Amazon C# SDK and trying to upload a file, but by default it has restricted permissions. I would like to make it publicly available, but I can't seem to find out how to do it as part of the upload.

My bucket is public, but when I upload a new file using the code below, the file I upload is not public.

Has anyone had to do this before?

MattoToddMattoTodd
5,79011 gold badges47 silver badges72 bronze badges

5 Answers

The solution by Tahbaza is correct, but it doesn't work in the later versions of AWS SDK (2.1+)...

Consider using the following for 2.1+ versions of SDK:

Web Api File Upload

danielonthenetdanielonthenet
Amazon s3 file upload api c#

Found it, need to use a TransferUtilityUploadRequest:

Amazon S3 File Upload Api CMattoToddMattoTodd
5,79011 gold badges47 silver badges72 bronze badges

I have done this before, and in C#, but not with your library (so this may be of limited help).

The idea is to send an ACL header along with the file.

S3 File Upload

This is one way to do it that should point you in the right direction.

Here's also a link to some relevant AWS docs.

TahbazaTahbaza

Google Drive

Upload
8,0221 gold badge22 silver badges38 bronze badges

Consider CannedACL approach, shown in the follwing snippet:

Ashraf AlamAshraf Alam

You can use the property CannedACL of Amazon.S3.Model.PutObjectRequest to upload files to S3 as shown below,

Sandeep JujareSandeep Jujare

Not the answer you're looking for? Browse other questions tagged c#amazon-s3 or ask your own question.