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();
}
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();
}
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();
}
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();
}
Aggregations