skip to Main Content

For example, s3 has three folders:

folder/folder1/subfolder1
folder/folder2/subfolder1
folder/folder2/subfolder2 

So I need path for all subfolder1. Expected answer:

folder/folder2/subfolder1
folder/folder1/subfolder1

2

Answers


  1. Chosen as BEST ANSWER
    List<S3ObjectSummary> listS3ObjectSummary= s3Local.listObjectsV2(amazonS3URI.getBucket()).getObjectSummaries();
    List<String> listPath= new ArrayList<>();
    listS3ObjectSummary.forEach(e->{e.getBucketName().contains("subfolder1");listPath.add(e.getBucketName());});
    

  2. According to this document https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#listObjectsV2-property,

    1. You can use the ListObjectsV2 method to retrieve the directory paths.
    2. Then filter the objects to get only the directories with the specified name
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search