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

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

Introduction

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

Prototype

public MultipleFileUpload uploadFileList(String bucketName, String virtualDirectoryKeyPrefix, File directory,
        List<File> files) 

Source Link

Document

Uploads all specified files to the bucket named, constructing relative keys depending on the commonParentDirectory given.

Usage

From source file:aws.example.s3.XferMgrUpload.java

License:Open Source License

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));
    }/*from   w w w.j a  va 2 s. c om*/

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