开发者

How to download a file via the browser from Amazon S3 using Python (and boto) at Google App Engine?

开发者 https://www.devze.com 2022-12-17 12:56 出处:网络
I have a python script running inside the Google App Engine with boto 1.9b that gets all keys inside a S3-Bucket. The output is formated as a HTML-Table.

I have a python script running inside the Google App Engine with boto 1.9b that gets all keys inside a S3-Bucket. The output is formated as a HTML-Table.

bucket_instance = conn_s3.get_bucket(bucketname)
liste_keys = bucket_instance.get_all_keys()

table = '<table>'
for i in range(laenge_liste_keys):
  table = table + '<tr><td>'+str(liste_keys[i].开发者_高级运维name)+</td></tr>'
table = '</table>'

How can I realize the key-names as links that enable the user to download the key via the browser?

Thanks in advance!


The solution is found.

generate_url(expires_in, method='GET', headers=None, query_auth=True, force_http=False)

This makes it easy to create a link for every key which is valid for x seconds.


The public URL for the file would be something like:

http://s3.amazonaws.com/bucket_name/key_name  

So in your code, add links with their href attributes pointing to that URL.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号