How to set the permission on files at the time of Upload through Amazon s3 API

青春壹個敷衍的年華 提交于 2019-12-06 05:41:52

Add a header to your PUT request:

x-amz-acl: public-read

Rahul Soni

In C# when you create a response object of >mazon then in response method you will find Addheader.

You need to set header as

response.Addheader("x-amz-acl","public-read");

Amazon providing these methods in its web services API kindly refer that.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!