Java 类com.amazonaws.services.s3.transfer.MultipleFileDownload 实例源码

项目:aws-doc-sdk-examples    文件:XferMgrDownload.java   
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();
}
项目:aws    文件:DownloadFiles.java   
public static void main(String[] args) throws Exception {
    TransferManager tm=new TransferManager(AWSResources.CREDENTIALS_PROVIDER);
    File destinationDirectory=new File("/tmp/downloads");
    if(!destinationDirectory.exists())
        destinationDirectory.mkdirs();
    MultipleFileDownload download= tm.downloadDirectory(AWSResources.S3_BUCKET_NAME, "photos/", destinationDirectory);
    download.addProgressListener(new SwingProgressListener(download));
}
项目:herd    文件:S3OperationsImpl.java   
@Override
public MultipleFileDownload downloadDirectory(String s3BucketName, String s3KeyPrefix, File destinationDirectory, TransferManager transferManager)
{
    return transferManager.downloadDirectory(s3BucketName, s3KeyPrefix, destinationDirectory);
}
项目:herd    文件:MockS3OperationsImpl.java   
/**
 * {@inheritDoc}
 * <p/>
 * This implementation creates any directory that does not exist in the path to the destination directory.
 */
@Override
public MultipleFileDownload downloadDirectory(String bucketName, String keyPrefix, File destinationDirectory, TransferManager transferManager)
{
    LOGGER.debug("downloadDirectory(): bucketName = " + bucketName + ", keyPrefix = " + keyPrefix + ", destinationDirectory = " + destinationDirectory);

    MockS3Bucket mockS3Bucket = mockS3Buckets.get(bucketName);

    List<Download> downloads = new ArrayList<>();
    long totalBytes = 0;

    if (mockS3Bucket != null)
    {
        for (MockS3Object mockS3Object : mockS3Bucket.getObjects().values())
        {
            if (mockS3Object.getKey().startsWith(keyPrefix))
            {
                String filePath = destinationDirectory.getAbsolutePath() + "/" + mockS3Object.getKey();
                File file = new File(filePath);
                file.getParentFile().mkdirs(); // Create any directory in the path that does not exist.
                try (FileOutputStream fileOutputStream = new FileOutputStream(file))
                {
                    LOGGER.debug("downloadDirectory(): Writing file " + file);
                    fileOutputStream.write(mockS3Object.getData());
                    totalBytes += mockS3Object.getData().length;
                    downloads.add(new DownloadImpl(null, null, null, null, null, new GetObjectRequest(bucketName, mockS3Object.getKey()), file,
                        mockS3Object.getObjectMetadata(), false));
                }
                catch (IOException e)
                {
                    throw new RuntimeException("Error writing to file " + file, e);
                }
            }
        }
    }

    TransferProgress progress = new TransferProgress();
    progress.setTotalBytesToTransfer(totalBytes);
    progress.updateProgress(totalBytes);

    MultipleFileDownloadImpl multipleFileDownload = new MultipleFileDownloadImpl(null, progress, null, keyPrefix, bucketName, downloads);
    multipleFileDownload.setState(TransferState.Completed);
    return multipleFileDownload;
}
项目:deeplearning4j    文件:S3Downloader.java   
public MultipleFileDownload downloadFolder(String bucketName, String keyPrefix, File folderPath) {
    TransferManager transfer = new TransferManager(getClient());
    return transfer.downloadDirectory(bucketName, keyPrefix, folderPath);
}
项目:herd    文件:S3Operations.java   
/**
 * Downloads all objects in the virtual directory designated by the key prefix given to the destination directory given.
 *
 * @param s3BucketName the S3 bucket name
 * @param s3KeyPrefix the S3 key prefix
 * @param destinationDirectory the destination directory
 * @param transferManager the transfer manager implementation to use
 *
 * @return the object that represents an asynchronous multiple file download of an entire virtual directory
 */
public MultipleFileDownload downloadDirectory(String s3BucketName, String s3KeyPrefix, File destinationDirectory, TransferManager transferManager);