List of usage examples for com.amazonaws.services.s3.transfer TransferManager upload
public Upload upload(final PutObjectRequest putObjectRequest) throws AmazonServiceException, AmazonClientException
Schedules a new transfer to upload data to Amazon S3.
From source file:org.finra.herd.dao.impl.S3OperationsImpl.java
License:Apache License
@Override public Upload upload(PutObjectRequest putObjectRequest, TransferManager transferManager) { return transferManager.upload(putObjectRequest); }
From source file:org.opendedup.sdfs.filestore.cloud.BatchAwsS3ChunkStore.java
License:Open Source License
private void multiPartUpload(PutObjectRequest req) throws AmazonServiceException, AmazonClientException, InterruptedException { TransferManager tx = null; try {// ww w . j a v a 2 s . co m if (awsCredentials != null) tx = new TransferManager(awsCredentials); else tx = new TransferManager(new InstanceProfileCredentialsProvider()); Upload myUpload = tx.upload(req); myUpload.waitForCompletion(); } finally { if (tx != null) tx.shutdownNow(); } }
From source file:org.xmlsh.aws.gradle.s3.AmazonS3ProgressiveFileUploadTask.java
License:BSD License
@TaskAction public void upload() throws InterruptedException { // to enable conventionMappings feature String bucketName = getBucketName(); String key = getKey();//from w w w. j a v a 2 s . c o m File file = getFile(); if (bucketName == null) throw new GradleException("bucketName is not specified"); if (key == null) throw new GradleException("key is not specified"); if (file == null) throw new GradleException("file is not specified"); if (file.isFile() == false) throw new GradleException("file must be regular file"); AmazonS3PluginExtension ext = getProject().getExtensions().getByType(AmazonS3PluginExtension.class); AmazonS3 s3 = ext.getClient(); TransferManager s3mgr = new TransferManager(s3); getLogger().info("Uploading... s3://{}/{}", bucketName, key); Upload upload = s3mgr.upload( new PutObjectRequest(getBucketName(), getKey(), getFile()).withMetadata(getObjectMetadata())); upload.addProgressListener(new ProgressListener() { public void progressChanged(ProgressEvent event) { getLogger().info(" {}% uploaded", upload.getProgress().getPercentTransferred()); } }); upload.waitForCompletion(); setResourceUrl(((AmazonS3Client) s3).getResourceUrl(bucketName, key)); getLogger().info("Upload completed: {}", getResourceUrl()); }