Help us understand the problem. What is going on with this article?

botoでS3の署名付きURLを生成する

More than 5 years have passed since last update.

PythonのAWS SDKであるbotoを使ってS3の署名付きURLを生成する。

URLだけを生成する

1つのアイテムのURLを生成するだけならコネクションから直接生成するのがお手軽な方法。

conn = boto.connect_s3(aws_access_key_id, aws_secret_access_key)
url = conn.generate_url(expire_second, method='GET',
                        bucket='bucket_name', key='path/to/file')

Bucketオブジェクトを生成してから生成する

バケットの中のアイテムを探しながらの場合はこちらの方が楽。

conn = boto.connect_s3(aws_access_key_id, aws_secret_access_key)
bucket = conn.get_bucket('bucket_name')
key = bucket.get_key('path/to/file')
url = key.generate_url(expire_second)

全リストならこんな感じ。

bucket = (boto.connect_s3(aws_access_key_id, aws_secret_access_key)
          .get_bucket('bucket_name'))
for key in bucket.get_all_keys():
    print(key.generate_url(60))

参考

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした