如何为查看基于 Amazon S3 的静态网站的用户提供目录列表?
我有一个 Amazon S3 帐户,我想在其中存储多个文件目录。
我希望该网站的访问者能够查看并下载我放置在那里的文件和文件夹。
这些文件和文件夹会定期更改,我不希望每次添加或删除文件时都重写任何 html。
如何安排向我的网站的查看者呈现简单的文件/文件夹列表?
I have an Amazon S3 account where I would like to store several directories of files.
I would like a visitor to this site to be able to see and download the files and folders I have placed there.
These files and folders will change regularly and I would prefer not to have to rewrite any html each time I added or removed files.
How can I arrange for the viewers of my site to be presented with a simple list of files/ folders?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 Javascript 列出文件。
以下是亚马逊提供的解决方案:
http://aws.amazon.com/code/Amazon -S3/1713
将 list.html 放置在要列出的每个目录中。
我制作了自己的列表文件,提供可折叠的树视图:
https://github .com/phatmann/jS3Tree/blob/master/index.html
如果您使用 S3 网站功能,这些文件都不起作用。
You can use Javascript to list the files.
Here is the solution provided by Amazon:
http://aws.amazon.com/code/Amazon-S3/1713
You place list.html in every directory you want to list.
I have made my own listing file that provides a collapsible tree view:
https://github.com/phatmann/jS3Tree/blob/master/index.html
Neither of these files will work if you are using the S3 website feature.
我创建了一个简单的 JS 代码,它以 HTML 样式创建了一个适合您要查找的内容的目录索引: https: //github.com/rgrp/s3-bucket-listing
您可以将其直接安装到您的 s3 存储桶中或安装到单独的网站中(感谢 S3 REST API 支持 CORS!)。自述文件对此有完整说明:https://github.com/rgrp/s3-bucket-listing
I've created a simple bit of JS that creates a directory index in HTML style that would fit what you are looking for: https://github.com/rgrp/s3-bucket-listing
You can install this either directly into your s3 bucket or into a separate website (thanks to the fact that the S3 REST API supports CORS!). The README has full instructions on this: https://github.com/rgrp/s3-bucket-listing
您应该使用 Amazon S3 API 列出存储桶及其中的文件
存储桶可以代表一个文件夹(比在文件名上使用前缀更容易)
创建存储桶并将文件上传到其中后,
您可以使用 列出我的所有存储桶 请求
一旦用户单击给定存储桶,您就可以使用 列表存储桶 请求获取其中的文件< br>最后一次单击该文件以生成该对象的 url,以便用户可以下载它而不会浪费带宽,
您可以找到许多 amazon s3 api 的实现 此处
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