开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜