简体   繁体   English

使用boto3从公共存储桶下载

[英]Use boto3 to download from public bucket

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. 我正在尝试列出AWS上一个公共存储桶中的文件,但我得到的最好的结果是列出了我自己的存储桶和我自己的文件。 I'm assuming that boto3 is using my credentials configured in the system to list my things. 我假设boto3使用系统中配置的凭据列出我的东西。

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. 谢谢你帮我

Pass the region_name when creating the client 创建客户端时传递region_name

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

Then list objects from the bucket 然后从存储桶中列出对象

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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