简体   繁体   中英

How to list content from a public Amazon s3 bucket

I have configured my bucket to be public, which means everyone can view the bucket as: http://bucket.s3-website-us-east-1.amazonaws.com/

Now I need to be able to get the list of objects and download it if required.

I found answers on this very helpful in getting me setup on python: Quick way to list all files in Amazon S3 bucket?

This work fine if I input the access-key and secret-access-key.

The problem though is we might have people accessing the bucket who we don't want to have any keys at all. So if the keys are not provided it gives me 400 Bad Response error.

At first I thought this might be impossible. But extensive search led me to this R-package: Cloudyr R package

Using this I am able to full the objects without need of the keys:

get_bucket(bucket = 'bucket')

in R but the functionalities are limited in listing/downloading the files. Any ideas how I go about doing this in boto?

The default S3 policy is all deny ,so you need to set permission policy to it

  • choose your bucket and click property
  • add more permissions grantee everyone can list
  • edit bucket policy get object

I think what you need is Bucket Policy which will allow for anonymous to read objects stored.

Granting Read-Only Permission to an Anonymous User should help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM