List in-progress multipart uploads to an Amazon S3 bucket using an AWS SDK - Amazon Simple Storage Service

List in-progress multipart uploads to an Amazon S3 bucket using an AWS SDK

The following code example shows how to list in-progress multipart uploads to an S3 bucket.

SDK for Java 2.x

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

import; import; import; import; import; import; import java.util.List; /** * Before running this Java V2 code example, set up your development environment, including your credentials. * * For more information, see the following documentation topic: * * */ public class ListMultipartUploads { public static void main(String[] args) { final String usage = """ Usage: <bucketName>\s Where: bucketName - The name of the Amazon S3 bucket where an in-progress multipart upload is occurring. """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String bucketName = args[0]; Region region = Region.US_EAST_1; S3Client s3 = S3Client.builder() .region(region) .build(); listUploads(s3, bucketName); s3.close(); } public static void listUploads(S3Client s3, String bucketName) { try { ListMultipartUploadsRequest listMultipartUploadsRequest = ListMultipartUploadsRequest.builder() .bucket(bucketName) .build(); ListMultipartUploadsResponse response = s3.listMultipartUploads(listMultipartUploadsRequest); List<MultipartUpload> uploads = response.uploads(); for (MultipartUpload upload : uploads) { System.out.println("Upload in progress: Key = \"" + upload.key() + "\", id = " + upload.uploadId()); } } catch (S3Exception e) { System.err.println(e.getMessage()); System.exit(1); } } }

For a complete list of AWS SDK developer guides and code examples, see Using this service with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.