Can we get the folder name only in S3?

29 Views Asked by At

I have close to 1 Million objects in a bucket. I want to list the folders to a certain level alone without listing all the 1 million files - similar to how we can in file storage.

Eg: If bucket1 contains the following files then:
bucket1/1/xyz/**.pdf
bucket1/1/xyz/***.pdf
bucket1/1/xyz/*****.pdf
bucket1/1/yzx/*.pdf
bucket1/1/yzx/**.pdf
bucket1/1/yzx/***.pdf
bucket1/2/xyz/***.pdf
bucket1/3/xyz/***.pdf
.
.
1 million files

O/P should be only the folders.
bucket1/1/xyz/
bucket1/1/yzx/
bucket1/2/xyz/
bucket1/3/xyz/

Is there any workaround in s3 api to list the folders without going to the leaf files?

0

There are 0 best solutions below