Use boto3 to download from public bucket

…衆ロ難τιáo~ 提交于 2021-01-27 18:30:46

问题


I'm trying to list files from a public bucket on AWS but the best I got was list my own bucket and my own files. I'm assuming that boto3 is using my credentials configured in the system to list my things.

How can I force it to list from a specific bucket, rather than my own bucket?

#http://sentinel-s2-l1c.s3-website.eu-central-1.amazonaws.com/
g_bucket = "sentinel-s2-l1c"
g_zone = "eu-central-1"

Thank you for helping me out.


回答1:


Pass the region_name when creating the client

s3client = boto3.client('s3', region_name='eu-central-1')

Then list objects from the bucket

objects = s3client.list_objects(Bucket='sentinel-s2-l1c')


来源:https://stackoverflow.com/questions/42090830/use-boto3-to-download-from-public-bucket

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