views:

12

answers:

2

Is there any way to set the file permission at the time of uploading files through Amazon S3 API.

In my current solution i am able to upload the file on my bucket but i can not view the file through the URL which is mentioned in the file properties section. It is opening when i am passing access keys in query string.

Is there any settings required in Amazon S3 or i need to set the permissions to all the file at the time of upload.

Thanks in Advance.

Kamal Kant Pansari

A: 

Add a header to your PUT request:

x-amz-acl: public-read

Coronatus
A: 

Hi,

You can also use Bucket Policies feature.

Here is an example of bucket policy that instructs amazon s3 to make all of the files publicly available, including new files you will upload:

{
  "Version":"2008-10-17",
  "Statement":[{
    "Sid":"AllowPublicRead",
        "Effect":"Allow",
      "Principal": {
            "AWS": "*"
         },
      "Action":["s3:GetObject"],
      "Resource":["arn:aws:s3:::your.bucket.name/*"
      ]
    }
  ]
}

Replace your.bucket.name with your actual bucket name

You can view and edit Bucket Policies with S3 Browser Freeware. You can find more Bucket Policies examples here.

S3 Browser Team