Java Code Examples for com.amazonaws.services.s3.transfer.TransferManager#downloadDirectory()
The following examples show how to use
com.amazonaws.services.s3.transfer.TransferManager#downloadDirectory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XferMgrDownload.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
public static void downloadDir(String bucket_name, String key_prefix, String dir_path, boolean pause) { System.out.println("downloading to directory: " + dir_path + (pause ? " (pause)" : "")); // snippet-start:[s3.java1.s3_xfer_mgr_download.directory] TransferManager xfer_mgr = TransferManagerBuilder.standard().build(); try { MultipleFileDownload xfer = xfer_mgr.downloadDirectory( bucket_name, key_prefix, new File(dir_path)); // loop with Transfer.isDone() XferMgrProgress.showTransferProgress(xfer); // or block with Transfer.waitForCompletion() XferMgrProgress.waitForCompletion(xfer); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } xfer_mgr.shutdownNow(); // snippet-end:[s3.java1.s3_xfer_mgr_download.directory] }
Example 2
Source File: S3DownloadStep.java From pipeline-aws-plugin with Apache License 2.0 | 5 votes |
@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("/")) { try { final MultipleFileDownload fileDownload = mgr.downloadDirectory(this.bucket, this.path, localFile); fileDownload.waitForCompletion(); RemoteDownloader.this.taskListener.getLogger().println("Finished: " + fileDownload.getDescription()); } finally { mgr.shutdownNow(); } return null; } else { try { 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(); } finally { mgr.shutdownNow(); } return null; } }
Example 3
Source File: S3OperationsImpl.java From herd with Apache License 2.0 | 4 votes |
@Override public MultipleFileDownload downloadDirectory(String s3BucketName, String s3KeyPrefix, File destinationDirectory, TransferManager transferManager) { return transferManager.downloadDirectory(s3BucketName, s3KeyPrefix, destinationDirectory); }