2

我想在我的 EC2 实例上安装一些 Python 模块。我有在 S3 存储桶上安装所需的文件。我还可以通过 Python boto 从我的 EC2 实例连接到 S3 存储桶,但我无法访问存储桶内容来获取我需要安装的源文件。

4

2 回答 2

6

以防万一您想通过 boto 获取 Python 中的文件,这是一个简单的示例:

https://gist.github.com/1925584

如果您不喜欢以下链接:

import boto
import os

def download_keys(bucket_name, dst_dir):
    """
    Very simple example showing how to download all keys in a bucket.
    Assumes key names don't include path separators.  Also assumes that
    you don't have zillions of objects in the bucket.  If you have a lot
    you would want to get several download operations going in parallel.
    """
    s3 = boto.connect_s3()
    bucket = s3.lookup(bucket_name)
    for key in bucket:
        path = os.path.join(dst_dir, key.name)
        key.get_contents_to_filename(path)
于 2012-05-05T13:17:11.123 回答
2

使用 s3cmd 工具 (http://s3tools.org/s3cmd) 可以下载/上传存储在存储桶中的文件。

于 2012-05-05T11:42:03.290 回答