通过Web浏览器访问存储在Amazon S3上的文件 [英] Access files stored on Amazon S3 through web browser
问题描述
我在Github上有一个项目,该项目在 Travis-CI 上的每次提交之后生成.每次成功构建后,Travis都会将工件上传到S3存储桶.有什么办法可以让我轻松地让任何人访问存储桶中的文件?我知道我可以生成一个只读访问密钥,但是用户可以通过其网络浏览器访问文件.
I have a project on Github that builds after every commit on Travis-CI. After each successful build Travis uploads the artifacts to an S3 bucket. Is there some way for me to easily let anyone access the files in the bucket? I know I could generate a read-only access key, but it'd be easier for the user to access the files through their web browser.
我启用了根目录为."的网站托管.放.
I have website hosting enabled with the root document of "." set.
但是,尝试进入存储桶的端点时,我仍然收到403禁止访问.
However, I still get an 403 Forbidden when trying to go to the bucket's endpoint.
我如何让用户轻松地从其Web浏览器浏览和下载存储在Amazon S3上的工件?最好没有第三方客户端.
How can I let users easily browse and download artifacts stored on Amazon S3 from their web browser? Preferably without a third-party client.
推荐答案
I found this related question: Directory Listing in S3 Static Website
事实证明,如果为整个存储桶启用了公共读取,则S3可以提供目录列表.问题在于它们是XML而不是HTML,因此不是很友好.
As it turns out, if you enable public read for the whole bucket, S3 can serve directory listings. Problem is they are in XML instead of HTML, so not very user-friendly.
您可以通过三种方式生成列表:
There are three ways you could go for generating listings:
-
为您自己的计算机上的每个目录生成index.html文件,将它们上传到s3,并在将新文件添加到目录时进行更新.科技含量很低.由于您是说要直接从Travis上传构建文件,因此这可能不切实际,因为在那儿需要做额外的工作.
Generate index.html files for each directory on your own computer, upload them to s3, and update them whenever you add new files to a directory. Very low-tech. Since you're saying you're uploading build files straight from Travis, this may not be that practical since it would require doing extra work there.
使用客户端S3浏览器工具.
Use a client-side S3 browser tool.
-
Rulis Pollock的
- s3-bucket-listing
- s3-file-list-page (由Adam Pritchard提供) li>
- s3-bucket-listing by Rufus Pollock
- s3-file-list-page by Adam Pritchard
使用服务器端浏览器工具.
Use a server-side browser tool.
- s3browser (PHP)
- s3index Scala. Going by the existence of a Procfile, it may be readily deployable to Heroku. Not sure since I don't have any experience with Scala.
这篇关于通过Web浏览器访问存储在Amazon S3上的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!