Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I create a list of files stored in my Amazon S3 bucket and display them as download links?
    primarykey
    data
    text
    <p>I have a number of videos in an Amazon S3 bucket and I want to display them as a list on my website. Clicking on any item in the list will download the video.</p> <p>I am using Python and Flask. I currently have the urls and names displaying on screen but I cannot download them. In python it would be simple to just use the "get_file" function on the S3 key but I can't figure out how I would call this method. It seems like it should be simple to do but I may have to use javascript in html 'onClick.'</p> <p>I am new to javascript so that may be an option but I would most of all like to just access the built in boto method.</p> <p>Currently I have keys:</p> <pre><code>from boto.s3.connection import S3Connection def get_video_keys(): key = local_settings.local_vars['AWS_ACCESS_KEY_ID'] skey = local_settings.local_vars['AWS_SECRET_ACCESS_KEY'] bucket = local_settings.local_vars['VIDEO_BUCKET_NAME'] conn = S3Connection(key, skey) mybucket = conn.get_bucket(bucket) keys = mybucket.get_all_keys() return keys </code></pre> <p>And also some html to display them using Jinja2 templating.</p> <pre><code>{% for key in keys %} &lt;li&gt;&lt;div&gt;&lt;a href="{{ key.generate_url(3600) }}"&gt; {{ key.name }}&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; {% endfor %} </code></pre> <p>Looking on line has only found ways to download all files rather than downloading in response to a click event.</p> <p>UPDATE 9/5/13</p> <p>This actually works fine on Firefox but is not doing anything in Chrome/Chromium.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload