java - AWS S3 - Listing all objects inside a folder without the prefix -


i'm having problems retrieving objects(filenames) inside folder in aws s3. here's code:

listobjectsrequest listobjectsrequest = new listobjectsrequest()             .withbucketname(bucket)             .withprefix(foldername + "/")             .withmarker(foldername + "/")      objectlisting objectlisting = amazonwebservice.s3.listobjects(listobjectsrequest)      (s3objectsummary summary : objectlisting.getobjectsummaries()) {         print summary.getkey()     } 

it returns correct object prefix in it, e.g. foldename/filename

i know can use java perhaps substring exclude prefix wanted know if there method in aws sdk.

there not. linked list of methods available. reason behind s3 design. s3 not have "subfolders". instead list of files, filename "prefix" plus filename desire. gui shows data similar windows stored in "folders", there not folder logic present in s3.

http://docs.aws.amazon.com/awsjavasdk/latest/javadoc/com/amazonaws/services/s3/model/s3objectsummary.html

your best bet split "/" , take last object in array.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -