17

我有一个 Amazon S3 帐户,我想在其中存储多个文件目录。

我希望该站点的访问者能够查看和下载我放置在那里的文件和文件夹。

这些文件和文件夹会定期更改,我不希望每次添加或删除文件时都必须重写任何 html。

如何安排我的网站的查看者看到一个简单的文件/文件夹列表?

4

3 回答 3

9

您可以使用 Javascript 列出文件。

这是亚马逊提供的解决方案:

http://aws.amazon.com/code/Amazon-S3/1713

您将 list.html 放在要列出的每个目录中。

我制作了自己的列表文件,提供了一个可折叠的树视图:

https://github.com/phatmann/jS3Tree/blob/master/index.html

如果您使用的是 S3 网站功能,则这些文件都不起作用。

于 2011-06-12T13:46:49.037 回答
7

我创建了一个简单的 JS,它创建了一个 HTML 样式的目录索引,它适合您正在寻找的内容:https ://github.com/rgrp/s3-bucket-listing

您可以将它直接安装到您的 s3 存储桶或单独的网站中(感谢 S3 REST API 支持 CORS!)。自述文件对此有完整说明:https ://github.com/rgrp/s3-bucket-listing

于 2013-05-11T13:35:46.183 回答
0

you should use the Amazon S3 API to list the buckets and files within them
a bucket can represent a folder (will be easier than using prefix's on the file name)

after creating your buckets and uploading the files to them
you can present the buckets on a page with a List All My Buckets request
once a user clicks on a given bucket you can get the files in it using a List Bucket request
another last click on the file to generate a url for the object so the user can download it without wasting your bandwidth

you can find many implementations to the amazon s3 api here

于 2011-05-05T12:43:13.610 回答