com.amazonaws.services.s3.transfer.TransferManagerConfiguration Java Examples

The following examples show how to use com.amazonaws.services.s3.transfer.TransferManagerConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransferManagerFactoryTest.java    From circus-train with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldCreateDefaultTransferManagerClient() {
  S3S3CopierOptions s3Options = new S3S3CopierOptions(new HashMap<String, Object>() {{
    put(S3S3CopierOptions.Keys.MULTIPART_COPY_THRESHOLD.keyName(), MULTIPART_COPY_THRESHOLD_VALUE);
    put(S3S3CopierOptions.Keys.MULTIPART_COPY_PART_SIZE.keyName(), MULTIPART_COPY_PART_SIZE);
  }});

  TransferManagerFactory factory = new TransferManagerFactory();
  TransferManager transferManager = factory.newInstance(mockClient, s3Options);
  assertThat(transferManager.getAmazonS3Client(), is(mockClient));

  TransferManagerConfiguration managerConfig = transferManager.getConfiguration();
  assertThat(managerConfig.getMultipartCopyPartSize(), is(MULTIPART_COPY_PART_SIZE));
  assertThat(managerConfig.getMultipartCopyThreshold(), is(MULTIPART_COPY_THRESHOLD_VALUE));
}
 
Example #2
Source File: COSAPIClient.java    From stocator with Apache License 2.0 5 votes vote down vote up
private void initTransferManager() {
  TransferManagerConfiguration transferConfiguration =
      new TransferManagerConfiguration();
  transferConfiguration.setMinimumUploadPartSize(partSize);
  transferConfiguration.setMultipartUploadThreshold(multiPartThreshold);
  transferConfiguration.setMultipartCopyPartSize(partSize);
  transferConfiguration.setMultipartCopyThreshold(multiPartThreshold);

  transfers = new TransferManager(mClient, unboundedThreadPool);
  transfers.setConfiguration(transferConfiguration);
}
 
Example #3
Source File: S3OutputStream.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void upload() throws IOException {
	if (uploaded) {
		return;
	}
	try {
		uploaded = true;
		os.close();
		os = null;
		
		if (!S3InputStream.isS3File(url)) {
			throw new IllegalArgumentException("Not an Amazon S3 host");
		}
		
		String accessKey = S3InputStream.getAccessKey(url);
		String secretKey = S3InputStream.getSecretKey(url);
		String path = url.getFile();
		if (path.startsWith("/")) {
			path = path.substring(1);
		}
		
		AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
		AmazonS3Client service = new AmazonS3Client(credentials);
		transferManager = new TransferManager(service);
		TransferManagerConfiguration config = new TransferManagerConfiguration();
		config.setMultipartUploadThreshold(MULTIPART_UPLOAD_THRESHOLD);
		config.setMinimumUploadPartSize(MULTIPART_UPLOAD_THRESHOLD);
		transferManager.setConfiguration(config);
		
		String bucket = S3InputStream.getBucket(url);

		// CLO-4724:
		S3Utils.uploadFile(transferManager, tempFile, bucket, path);
		
	} finally {
		tempFile.delete();
		if (transferManager != null) {
			transferManager.shutdownNow();
		}
	}
}