使用boto3从公共存储桶下载 [英] Use boto3 to download from public bucket

查看:97
本文介绍了使用boto3从公共存储桶下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试列出AWS上一个公共存储桶中的文件,但是我得到的最好的结果是列出了我自己的存储桶和我自己的文件.我假设boto3使用系统中配置的凭据列出我的东西.

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"

谢谢您的帮助.

推荐答案

在创建客户端时传递 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')

这篇关于使用boto3从公共存储桶下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆