簡體   English   中英

如何從EC2實例導航到S3存儲桶文件夾?

[英]How can I navigate into S3 bucket folders from EC2 instance?

我想在我的EC2實例上安裝一些Python模塊。 我在S3存儲桶上有安裝所需的文件。 我也可以通過Python boto從EC2實例連接到S3存儲桶,但是我無法訪問存儲桶內容來獲取需要安裝的源文件。

萬一您想通過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)

使用s3cmd工具(http://s3tools.org/s3cmd),可以下載/上傳存儲在存儲桶中的文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM