0

I have been struggling reading nested folders stored on one of bucket on S3, using Scala. I wrote script with my credentials. In bucket - there are many folders. Let say one folder name is "folder1". In this folder there are many subfolders and so on. I want to get names of each subfolder(any each inside them) for folder1.

val yourAWSCredentials = new BasicAWSCredentials(AWS_ACCESS_KEY, AWS_SECRET_KEY)   
val amazonS3Client = new AmazonS3Client(yourAWSCredentials)

print(amazonS3Client.listObjects(bucketName,"folder1").getObjectSummaries())

But this returns not the structure I need. May be there is easier way to get the path?

xavi
  • 29
  • 1
  • 1
  • 8
  • What is the current output? – Callum May 22 '15 at 12:17
  • Current output is just an address of object. Not the real folders and names. If I move further like getObjectSummaries().get(1).getKey then I get some path. But its end file of last subdirectory. and if I change 2, its not in order as in usual file structure on disk. Thats why am unable to use looping with different indexes. – xavi May 22 '15 at 15:26

1 Answers1

0

Amazon S3 is not a regular hierarchical file system. It does not actually have folders.

You need to understand S3 prefixes and delimiters. See Listing Keys Hierarchically Using a Prefix and Delimiter.

Also see Max files per directory in S3.

Community
  • 1
  • 1
jarmod
  • 71,565
  • 16
  • 115
  • 122