views:

64

answers:

2

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!

+1  A: 

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.

Ralph Stevens
I'm not 100% sure, but I think, this works only with keys that have the ACL public-read.
Neverland
Correct. You can't read files that don't have public read access over the internet.
Ralph Stevens
+2  A: 

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.

Neverland