Neverland
Neverland

Reputation: 775

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!

Upvotes: 2

Views: 2064

Answers (2)

Neverland
Neverland

Reputation: 775

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.

Upvotes: 3

stepanian
stepanian

Reputation: 11433

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.

Upvotes: 2

Related Questions