Search in sources :

Example 16 with TransferManager

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

the class XferMgrUpload method uploadFileList.

public static void uploadFileList(String[] file_paths, String bucket_name, String key_prefix, boolean pause) {
    System.out.println("file list: " + Arrays.toString(file_paths) + (pause ? " (pause)" : ""));
    // convert the file paths to a list of File objects (required by the
    // uploadFileList method)
    ArrayList<File> files = new ArrayList<File>();
    for (String path : file_paths) {
        files.add(new File(path));
    }
    TransferManager xfer_mgr = new TransferManager();
    try {
        MultipleFileUpload xfer = xfer_mgr.uploadFileList(bucket_name, key_prefix, new File("."), files);
        // 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) ArrayList(java.util.ArrayList) AmazonServiceException(com.amazonaws.AmazonServiceException) File(java.io.File) MultipleFileUpload(com.amazonaws.services.s3.transfer.MultipleFileUpload)

Example 17 with TransferManager

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

the class XferMgrCopy method copyObjectSimple.

public static void copyObjectSimple(String from_bucket, String from_key, String to_bucket, String to_key) {
    System.out.println("Copying s3 object: " + from_key);
    System.out.println("      from bucket: " + from_bucket);
    System.out.println("     to s3 object: " + to_bucket);
    System.out.println("        in bucket: " + to_key);
    TransferManager xfer_mgr = new TransferManager();
    try {
        Copy xfer = xfer_mgr.copy(from_bucket, from_key, to_bucket, to_key);
        // 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) Copy(com.amazonaws.services.s3.transfer.Copy) AmazonServiceException(com.amazonaws.AmazonServiceException)

Example 18 with TransferManager

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

the class XferMgrDownload method downloadFile.

public static void downloadFile(String bucket_name, String key_name, String file_path, boolean pause) {
    System.out.println("Downloading to file: " + file_path + (pause ? " (pause)" : ""));
    File f = new File(file_path);
    TransferManager xfer_mgr = new TransferManager();
    try {
        Download xfer = xfer_mgr.download(bucket_name, key_name, f);
        // 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) AmazonServiceException(com.amazonaws.AmazonServiceException) File(java.io.File) MultipleFileDownload(com.amazonaws.services.s3.transfer.MultipleFileDownload) Download(com.amazonaws.services.s3.transfer.Download)

Example 19 with TransferManager

use of com.amazonaws.services.s3.transfer.TransferManager 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

TransferManager (com.amazonaws.services.s3.transfer.TransferManager)19 AmazonServiceException (com.amazonaws.AmazonServiceException)11 File (java.io.File)8 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)5 MultipleFileUpload (com.amazonaws.services.s3.transfer.MultipleFileUpload)5 ArrayList (java.util.ArrayList)4 AmazonClientException (com.amazonaws.AmazonClientException)3 DeleteObjectsRequest (com.amazonaws.services.s3.model.DeleteObjectsRequest)3 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)3 Region (com.amazonaws.services.s3.model.Region)3 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)3 TransferManagerConfiguration (com.amazonaws.services.s3.transfer.TransferManagerConfiguration)3 Upload (com.amazonaws.services.s3.transfer.Upload)3 Date (java.util.Date)3 Properties (java.util.Properties)3 DataStoreException (org.apache.jackrabbit.core.data.DataStoreException)3 NamedThreadFactory (org.apache.jackrabbit.core.data.util.NamedThreadFactory)3 ClientConfiguration (com.amazonaws.ClientConfiguration)2 MultipleFileDownload (com.amazonaws.services.s3.transfer.MultipleFileDownload)2 IOException (java.io.IOException)2