@Override
public Void invoke(File localFile, VirtualChannel channel) throws IOException, InterruptedException {
TransferManager mgr = TransferManagerBuilder.standard()
.withS3Client(AWSClientFactory.create(this.amazonS3ClientOptions.createAmazonS3ClientBuilder(), this.envVars))
.build();
if (this.path == null || this.path.isEmpty() || this.path.endsWith("/")) {
final MultipleFileDownload fileDownload = mgr.downloadDirectory(this.bucket, this.path, localFile);
fileDownload.waitForCompletion();
RemoteDownloader.this.taskListener.getLogger().println("Finished: " + fileDownload.getDescription());
return null;
} else {
final Download download = mgr.download(this.bucket, this.path, localFile);
download.addProgressListener((ProgressListener) progressEvent -> {
if (progressEvent.getEventType() == ProgressEventType.TRANSFER_COMPLETED_EVENT) {
RemoteDownloader.this.taskListener.getLogger().println("Finished: " + download.getDescription());
}
});
download.waitForCompletion();
return null;
}
}