S3 allow parent folder public directories folder?
I currently have public permissions for one of my S3 codes:
{
"Version": "2012-10-17",
"Id": "Policy1493660686651",
"Statement": [
{
"Sid": "Stmt1493660682556",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::polodata/*"
}
]
}
When the user navigates to a specific file, for example:, https://s3-us-west-2.amazonaws.com/polodata/ETHBTC.csv
it prompts the user to download - that's okay. However, when they navigate to: https://s3-us-west-2.amazonaws.com/polodata/
(no file specified), it returns an XML page.
What do I need to change for the latter to return a directory listing page?
source to share
When accessing the URL, you won't get the directory listing page from Amazon S3. The closest is a list of XML objects for which you must grant ListObjects
bucket policy permission . It looks like this:
This XML file has no 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>
Some people have come up with creative ways to model a directory listing, for example: Directory listing on a static S3 website
Remember - Amazon S3 is not a traditional web server. It is an object storage service that can serve content on the Internet as well. Thus, it will not behave exactly like a regular web server.
See also: How to set up an S3 bucket for static site hosting?
source to share