Giter Club home page Giter Club logo

s3-file-list-page's Introduction

PLEASE NOTE: DEPRECATED

This iframe hack is probably obviated by the introduction (2012-09-01) of CORS support in S3. As such, I don't guarantee that the demo site will remain up and running.

S3 File List Page

Demo

You can see this code in action here: http://www.provensecuritysolutions.com/ciphershare/

The Problem

This mini-project was born when I moved a site from standard GoDaddy hosting to Amazon S3's static site hosting. The site has a couple of directories of downloads that it had been directly browsable using .htaccess permissions. But that ability was lost with S3.

When looking for a solution to this problem, I found that it's possible if you're accessing access the bucket as a bucket-domain (www.example.com.s3.amazonaws.com); but cross-domain restrictions prevent that from working if you're using the bucket as a website (www.example.com, CNAME'd to something like www.example.com.s3-website-us-east-1.amazonaws.com). (The solution to this problem would be much easier and cleaner if AWS enabled/provided the Access-Control-Allow-Origin header.)

After much cross-domain failure I hit on the idea of using an iframe that is loaded directly from the bucket, so it's in the same domain as the S3 REST call we ultimately want to do.

A Solution

In this project you'll find two files: index.html and s3_file_list_iframe.html. The former loads the latter into an iframe. Because the iframe source is from the same domain as the

When index.html is loaded in a browser, the user will be shown an expandable tree of all directories and files located under the current directory (and its subdirectories).

Usage

  1. index.html should be renamed to whatever you've configured the "Index Document" to be in your S3 website bucket.

  2. Copy the files into the directory that you'd like to provide a listing for.

  3. Make sure that the bucket has List permission for Everyone, and that the files are publicly readable.

Compatibility

I've tested on Windows with Chrome, Firefox, and IE9.

If you're trying to use s3-file-list-page in conjunction with FuseOverAmazon, you should look at this (solved) issue.

Shortcomings

  • You have to give you bucket public list permission, which might not be a great idea. See Amazon S3 Bucket Public Access Considerations.

  • JavaScript is required. There's just no way around it. So no graceful degradation.

  • It would have been nice to use HTTPS when accessing the bucket directly, but there's a cert mismatch with www.example.com.s3.amazonaws.com, so no dice.

  • It would be good if index.html could get its own filename rather than using "index.html" explicitly when there's no filename in the location URL (i.e., when the "Index Document" is being hit). I couldn't figure out how to discover the implicit filename. So if you're using something other than "index.html" for your index filename, you should probably edit the ?ignore= part of the iframe src.

License

Licensed under the MIT license.

Copyright (c) 2012 Adam Pritchard

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

s3-file-list-page's People

Contributors

adam-p avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

s3-file-list-page's Issues

When a file and a directory have the same name, only the file appears

Hi,

First, I would like to thank you for your little script, it's really useful!

I'm trying to use it to list S3 directories created by FuseOverAmazon. For some (technical, I assume) reason, this file system represents a directory by an empty file + an S3 directory which share the same name. Unfortunately, s3-file-list-page does not seem to handle this case and only list the empty file.

Acceptable fix for me would be either to list both the empty file and the directory or to list the directory only.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.