本文整理汇总了Java中com.amazonaws.services.s3.model.AbortMultipartUploadRequest类的典型用法代码示例。如果您正苦于以下问题:Java AbortMultipartUploadRequest类的具体用法?Java AbortMultipartUploadRequest怎么用?Java AbortMultipartUploadRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbortMultipartUploadRequest类属于com.amazonaws.services.s3.model包,在下文中一共展示了AbortMultipartUploadRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: abortMultipartUpload
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest)
throws SdkClientException, AmazonServiceException {
abortMultipartUploadRequest = beforeClientExecution(abortMultipartUploadRequest);
rejectNull(abortMultipartUploadRequest,
"The request parameter must be specified when aborting a multipart upload");
rejectNull(abortMultipartUploadRequest.getBucketName(),
"The bucket name parameter must be specified when aborting a multipart upload");
rejectNull(abortMultipartUploadRequest.getKey(),
"The key parameter must be specified when aborting a multipart upload");
rejectNull(abortMultipartUploadRequest.getUploadId(),
"The upload ID parameter must be specified when aborting a multipart upload");
String bucketName = abortMultipartUploadRequest.getBucketName();
String key = abortMultipartUploadRequest.getKey();
Request<AbortMultipartUploadRequest> request = createRequest(bucketName, key, abortMultipartUploadRequest, HttpMethodName.DELETE);
request.addParameter("uploadId", abortMultipartUploadRequest.getUploadId());
populateRequesterPaysHeader(request, abortMultipartUploadRequest.isRequesterPays());
invoke(request, voidResponseHandler, bucketName, key);
}
示例2: abortMultipartUploads
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
/**
* <p>
* Aborts any multipart uploads that were initiated before the specified date.
* </p>
* <p>
* This method is useful for cleaning up any interrupted multipart uploads.
* <code>TransferManager</code> attempts to abort any failed uploads,
* but in some cases this may not be possible, such as if network connectivity
* is completely lost.
* </p>
*
* @param bucketName
* The name of the bucket containing the multipart uploads to
* abort.
* @param date
* The date indicating which multipart uploads should be aborted.
*/
public void abortMultipartUploads(String bucketName, Date date)
throws AmazonServiceException, AmazonClientException {
MultipartUploadListing uploadListing = s3.listMultipartUploads(appendSingleObjectUserAgent(
new ListMultipartUploadsRequest(bucketName)));
do {
for (MultipartUpload upload : uploadListing.getMultipartUploads()) {
if (upload.getInitiated().compareTo(date) < 0) {
s3.abortMultipartUpload(appendSingleObjectUserAgent(new AbortMultipartUploadRequest(
bucketName, upload.getKey(), upload.getUploadId())));
}
}
ListMultipartUploadsRequest request = new ListMultipartUploadsRequest(bucketName)
.withUploadIdMarker(uploadListing.getNextUploadIdMarker())
.withKeyMarker(uploadListing.getNextKeyMarker());
uploadListing = s3.listMultipartUploads(appendSingleObjectUserAgent(request));
} while (uploadListing.isTruncated());
}
示例3: performAbortMultipartUpload
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
/**
* Performs an
* {@link AmazonS3#abortMultipartUpload(AbortMultipartUploadRequest)}
* operation for the given multi-part upload.
*/
void performAbortMultipartUpload() {
if (multipartUploadId == null) {
return;
}
try {
AbortMultipartUploadRequest abortRequest = new AbortMultipartUploadRequest(origReq.getBucketName(), origReq.getKey(),
multipartUploadId)
.withRequesterPays(origReq.isRequesterPays());
s3.abortMultipartUpload(abortRequest);
} catch (Exception e2) {
log.info(
"Unable to abort multipart upload, you may need to manually remove uploaded parts: "
+ e2.getMessage(), e2);
}
}
示例4: cleanupFilestore
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
/**
* Deletes all existing buckets
*/
@After
public void cleanupFilestore() {
for (final Bucket bucket : s3Client.listBuckets()) {
if (!INITIAL_BUCKET_NAMES.contains(bucket.getName())) {
s3Client.listMultipartUploads(new ListMultipartUploadsRequest(bucket.getName()))
.getMultipartUploads()
.forEach(upload ->
s3Client.abortMultipartUpload(
new AbortMultipartUploadRequest(bucket.getName(), upload.getKey(),
upload.getUploadId()))
);
s3Client.deleteBucket(bucket.getName());
}
}
}
示例5: shouldAbortMultipartUpload
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
/**
* Tests if a multipart upload can be aborted.
*
* @throws Exception not expected
*/
@Test
public void shouldAbortMultipartUpload() throws Exception {
s3Client.createBucket(BUCKET_NAME);
assertThat(s3Client.listMultipartUploads(new ListMultipartUploadsRequest(BUCKET_NAME))
.getMultipartUploads(), is(empty()));
final InitiateMultipartUploadResult initiateMultipartUploadResult = s3Client
.initiateMultipartUpload(new InitiateMultipartUploadRequest(BUCKET_NAME, UPLOAD_FILE_NAME));
final String uploadId = initiateMultipartUploadResult.getUploadId();
assertThat(s3Client.listMultipartUploads(new ListMultipartUploadsRequest(BUCKET_NAME))
.getMultipartUploads(), is(not(empty())));
s3Client.abortMultipartUpload(
new AbortMultipartUploadRequest(BUCKET_NAME, UPLOAD_FILE_NAME, uploadId));
assertThat(s3Client.listMultipartUploads(new ListMultipartUploadsRequest(BUCKET_NAME))
.getMultipartUploads(), is(empty()));
}
示例6: testAtomicMpuAbort
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
@Test
public void testAtomicMpuAbort() throws Exception {
String key = "testAtomicMpuAbort";
ObjectMetadata metadata = new ObjectMetadata();
metadata.setContentLength(BYTE_SOURCE.size());
client.putObject(containerName, key, BYTE_SOURCE.openStream(),
metadata);
InitiateMultipartUploadRequest initRequest =
new InitiateMultipartUploadRequest(containerName, key);
InitiateMultipartUploadResult initResponse =
client.initiateMultipartUpload(initRequest);
String uploadId = initResponse.getUploadId();
client.abortMultipartUpload(new AbortMultipartUploadRequest(
containerName, key, uploadId));
S3Object object = client.getObject(containerName, key);
assertThat(object.getObjectMetadata().getContentLength()).isEqualTo(
BYTE_SOURCE.size());
try (InputStream actual = object.getObjectContent();
InputStream expected = BYTE_SOURCE.openStream()) {
assertThat(actual).hasContentEqualTo(expected);
}
}
示例7: cancel
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
@Override
public CompletableFuture<Void> cancel() {
if (cancellation == null) {
cancellation = CompletableFuture.runAsync(() ->
s3.abortMultipartUpload(new AbortMultipartUploadRequest(bucket, key, uploadId)));
}
return cancellation;
}
示例8: abort
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
public void abort() {
LOG.warn("Aborting multi-part upload with id '{}'", uploadId);
try {
client.abortMultipartUpload(new AbortMultipartUploadRequest(bucket,
key, uploadId));
} catch (Exception e2) {
LOG.warn("Unable to abort multipart upload, you may need to purge " +
"uploaded parts: " + e2, e2);
}
}
示例9: abortMultipartCopy
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
private void abortMultipartCopy() {
try {
AbortMultipartUploadRequest abortRequest = new AbortMultipartUploadRequest(
copyObjectRequest.getDestinationBucketName(),
copyObjectRequest.getDestinationKey(), multipartUploadId)
.withRequesterPays(copyObjectRequest.isRequesterPays());
s3.abortMultipartUpload(abortRequest);
} catch (Exception e) {
log.info(
"Unable to abort multipart upload, you may need to manually remove uploaded parts: "
+ e.getMessage(), e);
}
}
示例10: abortMultipartUploadSecurely
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
@Override
public void abortMultipartUploadSecurely(AbortMultipartUploadRequest req) {
if (defaultCryptoMode == EncryptionOnly)
eo.abortMultipartUploadSecurely(req);
else
ae.abortMultipartUploadSecurely(req);
}
示例11: onAbort
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
/**
* Notified from
* {@link AmazonS3EncryptionClient#uploadObject(UploadObjectRequest)} when
* failed to upload any part. This method is responsible for cancelling
* ongoing uploads and aborting the multi-part upload request.
*/
public void onAbort() {
for (Future<?> future : getFutures()) {
future.cancel(true);
}
if (uploadId != null) {
try {
s3.abortMultipartUpload(new AbortMultipartUploadRequest(
req.getBucketName(), req.getKey(), uploadId));
} catch (Exception e) {
LogFactory.getLog(getClass())
.debug("Failed to abort multi-part upload: " + uploadId, e);
}
}
}
示例12: abortAllMultipartUploads
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
private void abortAllMultipartUploads() {
ListMultipartUploadsRequest multipartUploadsRequest = new ListMultipartUploadsRequest(bucketName);
amazonS3.listMultipartUploads(multipartUploadsRequest)
.getMultipartUploads()
.forEach(upload -> {
AbortMultipartUploadRequest request = new AbortMultipartUploadRequest(bucketName, upload.getKey(), upload.getUploadId());
amazonS3.abortMultipartUpload(request);
});
}
示例13: abort
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
public void abort() {
log.warn("Aborting multi-part upload with id '{}'", uploadId);
try {
s3.abortMultipartUpload(new AbortMultipartUploadRequest(bucket, key, uploadId));
} catch (Exception e) {
// ignoring failure on abort.
log.warn("Unable to abort multipart upload, you may need to purge uploaded parts: ", e);
}
}
示例14: abortMultipartUpload
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
public void abortMultipartUpload(S3Upload upload) {
try {
runtimeCredentialsProvider.setAwsCredentials(upload.getAwsCredentials());
amazonS3.setRegion(Region.getRegion(Regions.fromName(upload.getRegion())));
amazonS3.abortMultipartUpload(new AbortMultipartUploadRequest(upload.getBucket(), upload.getKey(), upload.getUploadId()));
} catch (AmazonClientException e) {
throw new OmakaseRuntimeException(e);
}
}
示例15: abortMultipartUpload
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p/>
* This implementation simulates abort multipart upload operation.
*/
@Override
public void abortMultipartUpload(AbortMultipartUploadRequest abortMultipartUploadRequest, AmazonS3 s3Client)
{
// This method does nothing.
}