Directory Listing in S3 Static Website

Amazon S3Amazon Web-Services

Amazon S3 Problem Overview


I have set up an S3 bucket to host static files.

When using the website endpoint (http://.s3-website-us-east-1.amazonaws.com/): it forces me to set an index file. When the file isn't found, it throws an error instead of listing directory contents.

When using the s3 endpoint (.s3.amazonaws.com): I get an XML listing of the files, but I need an HTML listing that users can click the link to the file.

I have tried setting the permissions of all files and the bucket itself to "List" for "Everyone" in the AWS Console, but still no luck.

I have also tried some of the javascript alternatives, but they either don't work under the website url (that redirects to the index file) or just don't work at all. As a last resort, a collapsible javascript listing would be better than nothing, but I haven't found a good one.

Is this possible? If so, do I need to change permissions, ACL or something else?

Amazon S3 Solutions


Solution 1 - Amazon S3

I've created a simple bit of JS that creates a directory index in HTML style that you are looking for: https://github.com/rgrp/s3-bucket-listing

The README has specific instructions for handling Amazon S3 "website" buckets: https://github.com/rgrp/s3-bucket-listing#website-buckets

You can see a live example of the script in action on this s3 bucket (in website mode): http://data.openspending.org/

enter image description here

Solution 2 - Amazon S3

There is also this solution: https://github.com/caussourd/aws-s3-bucket-listing

Similar to https://github.com/rgrp/s3-bucket-listing but I couldn't make it work with Internet Explorer. So https://github.com/caussourd/aws-s3-bucket-listing works with IE and also add the possibility to order the files by names, size and date. On the downside, it doesn't follow folders: only the files at one level are displayed.

Solution 3 - Amazon S3

This might solve your problem. Security settings for Everyone group: (you need the bucketexplorer.com software for this)

If you are sharing files of HTTP, you may or may not want people to be able to list the contents of a bucket (folder.) If you want the bucket contents to be listed when someone enters the bucket name (http://s3.amazonaws.com/bucket_name/), then edit the Access Control List and give the Everyone group the access level of Read (and do likewise with the contents of the bucket.) If you don’t want the bucket contents list-able but do want to share the file within it, disable Read access for the Everyone group for the bucket itself, and then enable Read access for the individual files within the bucket.

Solution 4 - Amazon S3

I created a much simpler solution. Just place the index.html file in root of your folder and it will do the job. No configuration required. https://github.com/prabhatsharma/s3-directorylisting

Solution 5 - Amazon S3

I had a similar problem and created a JavaScript-and-iframe solution that works pretty well for listing directories in S3 website files. You just have to drop a couple of .html files into the directory you want to list. You can find it here: https://github.com/adam-p/s3-file-list-page

Solution 6 - Amazon S3

I found s3browser, which allowed me to set up a directory on the main web site that allowed browsing of the s3 bucket. It worked very well and was very easy to set up.

Solution 7 - Amazon S3

Using another approach base in pure JavaScript and AWS SDK JavaScript API. Not need PHP or other engine just pure web site (Apache or even IIS).

https://github.com/juvs/s3-bucket-browser

Not intent for deploy on your own bucket (for me, no make sense).

Using the new IAM Users from AWS you can provide more specific and secure access to your buckets. No need to publish your bucket to website and make all public.

If you want secure the access, you can use the conventional methods to authenticate users for your current web site.

Hope this help too!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioniJeepView Question on Stackoverflow
Solution 1 - Amazon S3Rufus PollockView Answer on Stackoverflow
Solution 2 - Amazon S3Céline AussourdView Answer on Stackoverflow
Solution 3 - Amazon S3TonyView Answer on Stackoverflow
Solution 4 - Amazon S3PrabhatView Answer on Stackoverflow
Solution 5 - Amazon S3adam-pView Answer on Stackoverflow
Solution 6 - Amazon S3iJeepView Answer on Stackoverflow
Solution 7 - Amazon S3JuvsView Answer on Stackoverflow