S3允许公用目录列出父文件夹吗? [英] S3 allow public directory listing of parent folder?
问题描述
我目前对我的一个S3存储桶具有公共权限,如下所示:
I currently have public permissions for one of my S3 buckets like so:
{
"Version": "2012-10-17",
"Id": "Policy1493660686651",
"Statement": [
{
"Sid": "Stmt1493660682556",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::polodata/*"
}
]
}
当用户导航到诸如https://s3-us-west-2.amazonaws.com/polodata/ETHBTC.csv
之类的特定文件时,它会提示用户下载-很好.但是,当他们导航到:https://s3-us-west-2.amazonaws.com/polodata/
(未指定文件)时,它将返回一个XML页面.
When a user navigates to a specific file like: https://s3-us-west-2.amazonaws.com/polodata/ETHBTC.csv
, it prompts the user to download -- which is fine. However, when they navigate to: https://s3-us-west-2.amazonaws.com/polodata/
(without the file specified), it returns an XML page.
我需要更改什么,以便后者返回目录列表页面?
What do I need to change so that the latter returns a directory listing page?
推荐答案
访问URL时,您不会从Amazon S3中获得目录列表页面.最接近的是对象的XML列表,您必须为其授予对存储桶策略的ListObjects
权限.看起来像这样:
You won't get a directory listing page out of Amazon S3 when accessing the URL. The closest is the XML list of objects, for which you must grant ListObjects
permission on the bucket policy. It looks like this:
此XML文件似乎没有与之关联的任何样式信息.文档树如下所示.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<Name>my-bucket</Name>
<Prefix/>
<Marker/>
<MaxKeys>1000</MaxKeys>
<IsTruncated>false</IsTruncated>
<Contents>
<Key>foo.txt</Key>
<LastModified>2017-05-01T21:07:13.000Z</LastModified>
<ETag>"9311482f31be49fb2f41be9e16097a9c"</ETag>
<Size>213</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>my-folder/</Key>
<LastModified>2017-05-01T21:07:18.000Z</LastModified>
<ETag>"d41d8cd98f00b204e9800998ecf8427e"</ETag>
<Size>0</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
<Contents>
<Key>my-folder/bar.txt</Key>
<LastModified>2017-05-01T21:07:30.000Z</LastModified>
<ETag>"9311482f31be49fb2f41be9e16097a9c"</ETag>
<Size>213</Size>
<StorageClass>STANDARD</StorageClass>
</Contents>
</ListBucketResult>
有些人想出了一些创新的方法来模拟目录列表,例如: S3中的目录列表静态网站
Some people have come up with creative ways of simulating a directory listing, eg: Directory Listing in S3 Static Website
请记住-Amazon S3不是传统的Web服务器.这是一种对象存储服务,它还可以将内容提供给Internet.因此,它的行为与普通的Web服务器完全不同.
Remember -- Amazon S3 isn't a traditional web server. It's an object storage service that can also serve content to the Internet. So, it won't behave exactly the same as a normal web server.
这篇关于S3允许公用目录列出父文件夹吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!