Amazon Simple Storage Service
개발자 안내서 (API 버전 2006-03-01)

멀티파트 업로드 중단

다음 예제에서는 상위 수준 Java API(TransferManager 클래스)를 사용하여 1주일 이상 전에 특정 버킷에서 시작된 진행 중인 멀티파트 업로드를 모두 중단합니다. 실제 예제를 작성 및 테스트하는 방법에 대한 자세한 내용은 Amazon S3 Java 코드 예제 테스트 단원을 참조하십시오.

// Copyright 2018, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: MIT-0 (For details, see import java.util.Date; import com.amazonaws.AmazonServiceException; import com.amazonaws.SdkClientException; import com.amazonaws.auth.profile.ProfileCredentialsProvider; import; import; import; import; public class HighLevelAbortMultipartUpload { public static void main(String[] args) { String clientRegion = "*** Client region ***"; String bucketName = "*** Bucket name ***"; try { AmazonS3 s3Client = AmazonS3ClientBuilder.standard() .withRegion(clientRegion) .withCredentials(new ProfileCredentialsProvider()) .build(); TransferManager tm = TransferManagerBuilder.standard() .withS3Client(s3Client) .build(); // sevenDays is the duration of seven days in milliseconds. long sevenDays = 1000 * 60 * 60 * 24 * 7; Date oneWeekAgo = new Date(System.currentTimeMillis() - sevenDays); tm.abortMultipartUploads(bucketName, oneWeekAgo); } catch(AmazonServiceException e) { // The call was transmitted successfully, but Amazon S3 couldn't process // it, so it returned an error response. e.printStackTrace(); } catch(SdkClientException e) { // Amazon S3 couldn't be contacted for a response, or the client couldn't // parse the response from Amazon S3. e.printStackTrace(); } } }