Amazon S3: How to get a list of folders in the bucket?

前端 未结 5 1151
野趣味
野趣味 2021-01-02 10:01

All that I found, it\'s this method GET Bucket But I can\'t understand how can I get only a list of folders in the current folder. Which prefix and delimiter I need to use?

5条回答
  •  没有蜡笔的小新
    2021-01-02 10:10

    What Anthony is missing here is that a folder doesn't necessarily have a key associated with it. If a file is created in S3, and given a key like "folder/name.ext", S3 will display a "folder" folder, but it doesn't have a key, meaning you're not getting it in your results.

    The only way to catch these folders is to look at the keys themselves, and regex the key name for the "/" character. If I knew C# a little better, I'd write you a code sample, but for reference here's a python example I wrote on another question.

提交回复
热议问题