简体   繁体   English

如何使用其 URL 从私有 S3 存储桶下载文件?

[英]How to download a file from private S3 bucket using its URL?

I have a file that is stored on AWS s3 at https://xyz.s3.amazonaws.com/foo/file.json and I want to download that into my local machine using Python.我有一个文件存储在 AWS s3 的https://xyz.s3.amazonaws.com/foo/file.json ,我想使用 Python 将其下载到我的本地机器中。 However, the URL cannot be accessed publicly.但是,该 URL 无法公开访问。 I have the Account ID, IAM user name, and password (but NO Access Key or Secret Access Key and no permissions to view/change them either) to the resource that contains this file.我拥有包含此文件的资源的账户 ID、IAM 用户名和密码(但没有访问密钥或秘密访问密钥,也没有查看/更改它们的权限)。 How can I programmatically download this file instead of doing so from the console?如何以编程方式下载此文件而不是从控制台下载?

You could generate an Amazon S3 pre-signed URL, which would allow a private object to be downloaded from Amazon S3 via a normal HTTPS call (eg curl).您可以生成一个 Amazon S3 预签名 URL,这将允许通过正常的 HTTPS 调用(例如 curl)从 Amazon S3 下载私有对象。 This can be done easily using the AWS SDK for Python, or you could code it yourself without using libraries.这可以使用适用于 Python 的 AWS 开发工具包轻松完成,或者您可以在不使用库的情况下自行编写代码。 Answer by John Rotenstein here John Rotenstein 的回答在这里

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

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