Search in sources :

Example 1 with MultipleFileDownload

use of com.amazonaws.services.s3.transfer.MultipleFileDownload in project aws-doc-sdk-examples by awsdocs.

the class XferMgrDownload method downloadDir.

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)" : ""));
    TransferManager xfer_mgr = new TransferManager();
    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();
}
Also used : TransferManager(com.amazonaws.services.s3.transfer.TransferManager) MultipleFileDownload(com.amazonaws.services.s3.transfer.MultipleFileDownload) AmazonServiceException(com.amazonaws.AmazonServiceException) File(java.io.File)

Aggregations

AmazonServiceException (com.amazonaws.AmazonServiceException)1 MultipleFileDownload (com.amazonaws.services.s3.transfer.MultipleFileDownload)1 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)1 File (java.io.File)1