aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

aws s3 ls --recursive in S3 SDK.

Open sushilkumarchaudhary opened this issue 8 years ago • 6 comments

folks, is there recursive way to listObjects using Amazon SDK.

sushilkumarchaudhary avatar Jul 20 '18 19:07 sushilkumarchaudhary

Is this what you are looking for?

https://github.com/aws/aws-sdk-java/blob/master/aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/iterable/S3Objects.java

shorea avatar Jul 20 '18 19:07 shorea

Probably. Is the Iterator iterator() I can use to iterate through all the folder/file inside a given s3 path? Does it do recursive iteration in each and every directory.

sushilkumarchaudhary avatar Jul 20 '18 21:07 sushilkumarchaudhary

Also, I do not the iterator to iterate. Instead get the list of everything under a folder.

sushilkumarchaudhary avatar Jul 20 '18 21:07 sushilkumarchaudhary

@sushilkumarchaudhary S3 doesn't really have the concept of a folder, it's a key/object store. That said certain tools interpret slashes in key names as folders or directories. You can limit the iteration to a specific prefix which is like limiting to a certain folder.

shorea avatar Jul 20 '18 21:07 shorea

Since aws CLI has option to pass —reclusive to get the Recursive listing, I was just thinking if SDK has some function on same line.

Thanks for the clarifying.

sushilkumarchaudhary avatar Jul 21 '18 01:07 sushilkumarchaudhary

Sure thing!

shorea avatar Jul 21 '18 21:07 shorea