I am trying to get the folders name from EMR. For example:
Prefix key = user/temp/
the bucket has the following objects:
user/temp/2000/1.txt
user/temp/2001/2.txt
user/temp/2002/3.txt
user/temp/2003/4.txt
So I need to get only:
2000,2001,2002,2003
I am doing the following:
val objectRequest = new ListObjectsRequest().withBucketName("com.temp").withPrefix("user/temp/").withDelimiter("/")
val files: ObjectListing = s3Client.listObjects(objectRequest)
I am getting 0 files
without the Delimiter I am getting:
user/temp/2000/1.txt
user/temp/2001/2.txt
user/temp/2002/3.txt
user/temp/2003/4.txt
I found it in the getCommonPrefix()