Search code examples
javaamazon-web-servicesamazon-s3awss3transfermanager

AWS Java SDK Transfer manager downloads only folder structure


When I tried to download all files of a specific folder from S3 using KeyPrefix, It downloads only the directory structure and not the files inside it.

Below is the code TransferManager xfer_mgr = TransferManagerBuilder.standard().build();

    File a = new File("./");
    try {
        GetObjectRequest gor = new GetObjectRequest(bucketName, "folder3");
        MultipleFileDownload xfer = xfer_mgr.downloadDirectory(
                bucketName, null, a);

    } catch (AmazonServiceException e) {
        System.err.println(e.getErrorMessage());
        System.exit(1);
    }
    System.out.println("done...............");

    xfer_mgr.shutdownNow();

Am I missing anything in the code, or Any permissions has to be added? Any Suggestions would be really helpful.


Solution

  • Solved It. Transfer manager downloads folder structure first and then all the files inside.

    So the Solution is: Making MultipleFileDownload xfer to 'waitForCompletion'.

    Adding a line xfer.waitForCompletion() solved the problem.