Example usage for com.amazonaws.services.s3.transfer TransferManager downloadDirectory

List of usage examples for com.amazonaws.services.s3.transfer TransferManager downloadDirectory

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.transfer TransferManager downloadDirectory.

Prototype

public MultipleFileDownload downloadDirectory(String bucketName, String keyPrefix, File destinationDirectory,
            boolean resumeOnRetry) 

Source Link

Usage

From source file:org.apache.flink.streaming.tests.util.s3.S3UtilProgram.java

License:Apache License

private static void downloadByFullPathAndFileNamePrefix(ParameterTool params) {
    final String bucket = params.getRequired("bucket");
    final String s3prefix = params.getRequired("s3prefix");
    final String localFolder = params.getRequired("localFolder");
    final String s3filePrefix = params.get("s3filePrefix", "");
    TransferManager tx = TransferManagerBuilder.defaultTransferManager();
    Predicate<String> keyPredicate = getKeyFilterByFileNamePrefix(s3filePrefix);
    KeyFilter keyFilter = s3filePrefix.isEmpty() ? KeyFilter.INCLUDE_ALL
            : objectSummary -> keyPredicate.test(objectSummary.getKey());
    try {//from   w w w . ja  v a 2  s.  c  om
        tx.downloadDirectory(bucket, s3prefix, new File(localFolder), keyFilter).waitForCompletion();
    } catch (InterruptedException e) {
        System.out.println("Transfer interrupted");
    } finally {
        tx.shutdownNow();
    }
}