本文整理汇总了Java中com.amazonaws.services.s3.model.CompleteMultipartUploadRequest类的典型用法代码示例。如果您正苦于以下问题:Java CompleteMultipartUploadRequest类的具体用法?Java CompleteMultipartUploadRequest怎么用?Java CompleteMultipartUploadRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompleteMultipartUploadRequest类属于com.amazonaws.services.s3.model包,在下文中一共展示了CompleteMultipartUploadRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: completeMultipartUploadSecurely
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
@Override
public CompleteMultipartUploadResult completeMultipartUploadSecurely(
CompleteMultipartUploadRequest req) {
appendUserAgent(req, USER_AGENT);
String uploadId = req.getUploadId();
final T uploadContext = multipartUploadContexts.get(uploadId);
if (uploadContext != null && !uploadContext.hasFinalPartBeenSeen()) {
throw new SdkClientException(
"Unable to complete an encrypted multipart upload without being told which part was the last. "
+ "Without knowing which part was the last, the encrypted data in Amazon S3 is incomplete and corrupt.");
}
CompleteMultipartUploadResult result = s3.completeMultipartUpload(req);
// In InstructionFile mode, we want to write the instruction file only
// after the whole upload has completed correctly.
if (uploadContext != null
&& cryptoConfig.getStorageMode() == InstructionFile) {
// Put the instruction file into S3
s3.putObject(createInstructionPutRequest(
uploadContext.getBucketName(), uploadContext.getKey(),
uploadContext.getContentCryptoMaterial()));
}
multipartUploadContexts.remove(uploadId);
return result;
}
示例2: close
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void close() {
if (!isOpen()) {
return;
}
closed = true;
uploadPendingParts();
CompletableFuture<Void>[] futures;
synchronized (workers) {
futures = workers.values().toArray(new CompletableFuture[workers.size()]);
}
CompletableFuture<Void> complete = CompletableFuture
.allOf(futures)
.thenApplyAsync((x) -> {
s3.completeMultipartUpload(new CompleteMultipartUploadRequest()
.withBucketName(bucket)
.withKey(key)
.withUploadId(uploadId)
.withPartETags(done));
return null;
}, executor);
try {
complete.get();
} catch (Exception e) {
cancel();
throw ExceptionUtils.mapExecutionException(e);
} finally {
tryCloseExecutor();
}
}
示例3: complete
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
public void complete(List<PartETag> partETags) {
if (LOG.isDebugEnabled()) {
LOG.debug("Completing multi-part upload for key '{}', id '{}'", key,
uploadId);
}
final CompleteMultipartUploadRequest completeRequest =
new CompleteMultipartUploadRequest(bucket, key, uploadId, partETags);
client.completeMultipartUpload(completeRequest);
}
示例4: call
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
@Override
public UploadResult call() throws Exception {
CompleteMultipartUploadResult res;
try {
CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest(
origReq.getBucketName(), origReq.getKey(), uploadId,
collectPartETags())
.withRequesterPays(origReq.isRequesterPays())
.withGeneralProgressListener(origReq.getGeneralProgressListener())
.withRequestMetricCollector(origReq.getRequestMetricCollector())
;
res = s3.completeMultipartUpload(req);
} catch (Exception e) {
publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
throw e;
}
UploadResult uploadResult = new UploadResult();
uploadResult.setBucketName(origReq
.getBucketName());
uploadResult.setKey(origReq.getKey());
uploadResult.setETag(res.getETag());
uploadResult.setVersionId(res.getVersionId());
monitor.uploadComplete();
return uploadResult;
}
示例5: uploadPartsInSeries
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
/**
* Uploads all parts in the request in serial in this thread, then completes
* the upload and returns the result.
*/
private UploadResult uploadPartsInSeries(UploadPartRequestFactory requestFactory) {
final List<PartETag> partETags = new ArrayList<PartETag>();
while (requestFactory.hasMoreRequests()) {
if (threadPool.isShutdown()) throw new CancellationException("TransferManager has been shutdown");
UploadPartRequest uploadPartRequest = requestFactory.getNextUploadPartRequest();
// Mark the stream in case we need to reset it
InputStream inputStream = uploadPartRequest.getInputStream();
if (inputStream != null && inputStream.markSupported()) {
if (uploadPartRequest.getPartSize() >= Integer.MAX_VALUE) {
inputStream.mark(Integer.MAX_VALUE);
} else {
inputStream.mark((int)uploadPartRequest.getPartSize());
}
}
partETags.add(s3.uploadPart(uploadPartRequest).getPartETag());
}
CompleteMultipartUploadRequest req =
new CompleteMultipartUploadRequest(
origReq.getBucketName(), origReq.getKey(), multipartUploadId,
partETags)
.withRequesterPays(origReq.isRequesterPays())
.withGeneralProgressListener(origReq.getGeneralProgressListener())
.withRequestMetricCollector(origReq.getRequestMetricCollector())
;
CompleteMultipartUploadResult res = s3.completeMultipartUpload(req);
UploadResult uploadResult = new UploadResult();
uploadResult.setBucketName(res.getBucketName());
uploadResult.setKey(res.getKey());
uploadResult.setETag(res.getETag());
uploadResult.setVersionId(res.getVersionId());
return uploadResult;
}
示例6: call
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
@Override
public CopyResult call() throws Exception {
CompleteMultipartUploadResult res;
try {
CompleteMultipartUploadRequest req = new CompleteMultipartUploadRequest(
origReq.getDestinationBucketName(), origReq.getDestinationKey(), uploadId,
collectPartETags())
.withRequesterPays(origReq.isRequesterPays())
.withGeneralProgressListener(origReq.getGeneralProgressListener())
.withRequestMetricCollector(origReq.getRequestMetricCollector())
;
res = s3.completeMultipartUpload(req);
} catch (Exception e) {
publishProgress(listener, ProgressEventType.TRANSFER_FAILED_EVENT);
throw e;
}
CopyResult copyResult = new CopyResult();
copyResult.setSourceBucketName(origReq.getSourceBucketName());
copyResult.setSourceKey(origReq.getSourceKey());
copyResult.setDestinationBucketName(res
.getBucketName());
copyResult.setDestinationKey(res.getKey());
copyResult.setETag(res.getETag());
copyResult.setVersionId(res.getVersionId());
monitor.copyComplete();
return copyResult;
}
示例7: completeMultipartUploadSecurely
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
@Override
public CompleteMultipartUploadResult completeMultipartUploadSecurely(
CompleteMultipartUploadRequest req)
throws SdkClientException, AmazonServiceException {
return defaultCryptoMode == EncryptionOnly
? eo.completeMultipartUploadSecurely(req)
: ae.completeMultipartUploadSecurely(req)
;
}
示例8: completeMultipartUpload
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
/**
* Complete a multipart upload operation.
* @param uploadId multipart operation Id
* @param partETags list of partial uploads
* @return the result
* @throws AmazonClientException on problems
*/
CompleteMultipartUploadResult completeMultipartUpload(String uploadId,
List<PartETag> partETags) throws AmazonClientException {
LOG.debug("Completing multipart upload {} with {} parts",
uploadId, partETags.size());
return mClient.completeMultipartUpload(
new CompleteMultipartUploadRequest(mBucket,
key,
uploadId,
partETags));
}
示例9: completeMultipartUpload
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
@Override
public CompletableFuture<CompleteMultipartUploadResult> completeMultipartUpload(String bucketName, String key,
String uploadId, List<PartETag> partETags) {
CompleteMultipartUploadRequest request
= new CompleteMultipartUploadRequest(bucketName, key, uploadId, partETags);
return CompletableFuture.supplyAsync(() -> s3Client.completeMultipartUpload(request), executorService);
}
示例10: verifyAndEmitFileMerge
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
/**
* Send the CompleteMultipartUploadRequest to S3 if all the blocks of a file are uploaded into S3.
* @param keyName file to upload into S3
*/
private void verifyAndEmitFileMerge(String keyName)
{
if (currentWindowId <= windowDataManager.getLargestCompletedWindow()) {
return;
}
S3InitiateFileUploadOperator.UploadFileMetadata uploadFileMetadata = fileMetadatas.get(keyName);
List<PartETag> partETags = uploadParts.get(keyName);
if (partETags == null || uploadFileMetadata == null ||
uploadFileMetadata.getFileMetadata().getNumberOfBlocks() != partETags.size()) {
return;
}
if (partETags.size() <= 1) {
uploadedFiles.add(keyName);
LOG.debug("Uploaded file {} successfully", keyName);
return;
}
CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest(bucketName,
keyName, uploadFileMetadata.getUploadId(), partETags);
CompleteMultipartUploadResult result = s3Client.completeMultipartUpload(compRequest);
if (result.getETag() != null) {
uploadedFiles.add(keyName);
LOG.debug("Uploaded file {} successfully", keyName);
}
}
示例11: completeMultipartUpload
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
public void completeMultipartUpload(S3Upload upload, List<S3Part> parts) {
try {
runtimeCredentialsProvider.setAwsCredentials(upload.getAwsCredentials());
amazonS3.setRegion(Region.getRegion(Regions.fromName(upload.getRegion())));
amazonS3.completeMultipartUpload(new CompleteMultipartUploadRequest(upload.getBucket(), upload.getKey(), upload.getUploadId(),
parts.stream().map(s3Part -> new PartETag(s3Part.getNumber(), s3Part.getEtag())).collect(Collectors.toList())));
} catch (AmazonClientException e) {
throw new OmakaseRuntimeException(e);
}
}
示例12: uploadFileSuccess
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
@Test
public void uploadFileSuccess() throws IOException {
TestUtils.initializeTestingFolders();
final File compressedFile = CompressionTools.compressFile(
"ZipProject",
PATH_TO_COMPRESS,
CompressionType.Zip,
null);
PublisherTools.uploadFile(
compressedFile,
mockArtifact,
CompressionType.Zip,
null, // No custom encryption key
mockS3Client,
null); // Listener
final InOrder inOrder = inOrder(mockS3Client);
inOrder.verify(mockS3Client, times(1)).initiateMultipartUpload(initiateCaptor.capture());
// Total size is less than 5MB, should only be one upload
inOrder.verify(mockS3Client, times(1)).uploadPart(any(UploadPartRequest.class));
inOrder.verify(mockS3Client, times(1)).completeMultipartUpload(any(CompleteMultipartUploadRequest.class));
assertContainsIgnoreCase("[AWS CodePipeline Plugin] Uploading artifact:", outContent.toString());
assertContainsIgnoreCase("[AWS CodePipeline Plugin] Upload successful", outContent.toString());
final InitiateMultipartUploadRequest request = initiateCaptor.getValue();
final SSEAwsKeyManagementParams encryptionParams = request.getSSEAwsKeyManagementParams();
assertNotNull(encryptionParams);
assertNull(encryptionParams.getAwsKmsKeyId());
assertEquals("aws:kms", encryptionParams.getEncryption());
compressedFile.delete();
TestUtils.cleanUpTestingFolders();
}
示例13: multipartUpload
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
private void multipartUpload(String key, File file, ObjectMetadata objectMetadata, Optional<StorageClass> maybeStorageClass) throws Exception {
List<PartETag> partETags = new ArrayList<>();
InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest(bucketName, key, objectMetadata);
if (maybeStorageClass.isPresent()) {
initRequest.setStorageClass(maybeStorageClass.get());
}
InitiateMultipartUploadResult initResponse = s3Client.initiateMultipartUpload(initRequest);
long contentLength = file.length();
long partSize = configuration.getUploadPartSize();
try {
long filePosition = 0;
for (int i = 1; filePosition < contentLength; i++) {
partSize = Math.min(partSize, (contentLength - filePosition));
UploadPartRequest uploadRequest = new UploadPartRequest()
.withBucketName(bucketName)
.withKey(key)
.withUploadId(initResponse.getUploadId())
.withPartNumber(i)
.withFileOffset(filePosition)
.withFile(file)
.withPartSize(partSize);
partETags.add(s3Client.uploadPart(uploadRequest).getPartETag());
filePosition += partSize;
}
CompleteMultipartUploadRequest completeRequest = new CompleteMultipartUploadRequest(bucketName, key, initResponse.getUploadId(), partETags);
s3Client.completeMultipartUpload(completeRequest);
} catch (Exception e) {
s3Client.abortMultipartUpload(new AbortMultipartUploadRequest(bucketName, key, initResponse.getUploadId()));
Throwables.propagate(e);
}
}
示例14: doCompleteMultipart
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
protected void doCompleteMultipart(S3BlobStore blobStore, String bucketName, String blobName, String uploadId, List<PartETag> parts)
throws AmazonS3Exception {
CompleteMultipartUploadRequest request = new CompleteMultipartUploadRequest(bucketName, blobName, uploadId, parts);
blobStore.client().completeMultipartUpload(request);
}
示例15: completeMultipartUpload
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest; //导入依赖的package包/类
@Override
public CompleteMultipartUploadResult completeMultipartUpload(CompleteMultipartUploadRequest request) throws AmazonClientException, AmazonServiceException {
return delegate.completeMultipartUpload(request);
}