Home > Back-end >  Is there a similar function like getSubTransfers for MultipleFileDownload? AWS Java SDK
Is there a similar function like getSubTransfers for MultipleFileDownload? AWS Java SDK

Time:02-17

I know that there is a function called getSubTransfers for the MultipleFileUpload, which I can use to retrieve the path of the file being uploaded to the AWS S3 bucket. I did my research and found nothing similar for the MultipleFileDownload. Here is the code that I used for Upload.

MultipleFileUpload upload = transferManager.uploadDirectory(bucket, cloudDir, localFolder, true);
Collection<? extends Upload> uploads = new ArrayList<Upload>();
uploads = upload.getSubTransfers();
for (Upload u : uploads) 
{
    System.out.println(u.getDescription());
}

Here is the code that I have for downloading the directory from S3:

MultipleFileDownload download = transferManager.downloadDirectory(bucket, cloudDir   "/", localFolder);

I am writing a client app in java that would print out the path of the current file being downloaded to the console. Any help on how to print the name of the current file being downloaded is appreciated.

CodePudding user response:

Unfortunately it looks like this is not supported currently.

There is a github request for this exact feature - https://github.com/aws/aws-sdk-java/issues/785

The good news is that it is being worked on - https://github.com/aws/aws-sdk-java-v2/issues/37

The closest workaround I can think of using the SDK is to use Transfer.getProgress() which will give you a TransferProgress object. Which has some properties like percentTransfered and some others... https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/TransferProgress.html

  • Related