Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use UploadMultipartPart with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use UploadMultipartPart with an AWS SDK or CLI

The following code examples show how to use UploadMultipartPart.

CLI
AWS CLI

The following command uploads the first 1 MiB (1024 x 1024 bytes) part of an archive:

aws glacier upload-multipart-part --body part1 --range 'bytes 0-1048575/*' --account-id - --vault-name my-vault --upload-id 19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ

Amazon Glacier requires an account ID argument when performing operations, but you can use a hyphen to specify the in-use account.

The body parameter takes a path to a part file on the local filesystem. The range parameter takes an HTTP content range indicating the bytes that the part occupies in the completed archive. The upload ID is returned by the aws glacier initiate-multipart-upload command and can also be obtained by using aws glacier list-multipart-uploads.

For more information on multipart uploads to Amazon Glacier using the AWS CLI, see Using Amazon Glacier in the AWS CLI User Guide.

JavaScript
SDK for JavaScript (v2)
Note

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

Create a multipart upload of 1 megabyte chunks of a Buffer object.

// Create a new service object and some supporting variables var glacier = new AWS.Glacier({ apiVersion: "2012-06-01" }), vaultName = "YOUR_VAULT_NAME", buffer = new Buffer(2.5 * 1024 * 1024), // 2.5MB buffer partSize = 1024 * 1024, // 1MB chunks, numPartsLeft = Math.ceil(buffer.length / partSize), startTime = new Date(), params = { vaultName: vaultName, partSize: partSize.toString() }; // Compute the complete SHA-256 tree hash so we can pass it // to completeMultipartUpload request at the end var treeHash = glacier.computeChecksums(buffer).treeHash; // Initiate the multipart upload console.log("Initiating upload to", vaultName); // Call Glacier to initiate the upload. glacier.initiateMultipartUpload(params, function (mpErr, multipart) { if (mpErr) { console.log("Error!", mpErr.stack); return; } console.log("Got upload ID", multipart.uploadId); // Grab each partSize chunk and upload it as a part for (var i = 0; i < buffer.length; i += partSize) { var end = Math.min(i + partSize, buffer.length), partParams = { vaultName: vaultName, uploadId: multipart.uploadId, range: "bytes " + i + "-" + (end - 1) + "/*", body: buffer.slice(i, end), }; // Send a single part console.log("Uploading part", i, "=", partParams.range); glacier.uploadMultipartPart(partParams, function (multiErr, mData) { if (multiErr) return; console.log("Completed part", this.request.params.range); if (--numPartsLeft > 0) return; // complete only when all parts uploaded var doneParams = { vaultName: vaultName, uploadId: multipart.uploadId, archiveSize: buffer.length.toString(), checksum: treeHash, // the computed tree hash }; console.log("Completing upload..."); glacier.completeMultipartUpload(doneParams, function (err, data) { if (err) { console.log("An error occurred while uploading the archive"); console.log(err); } else { var delta = (new Date() - startTime) / 1000; console.log("Completed upload in", delta, "seconds"); console.log("Archive ID:", data.archiveId); console.log("Checksum: ", data.checksum); } }); }); } });
AWS CLI

The following command uploads the first 1 MiB (1024 x 1024 bytes) part of an archive:

aws glacier upload-multipart-part --body part1 --range 'bytes 0-1048575/*' --account-id - --vault-name my-vault --upload-id 19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ

Amazon Glacier requires an account ID argument when performing operations, but you can use a hyphen to specify the in-use account.

The body parameter takes a path to a part file on the local filesystem. The range parameter takes an HTTP content range indicating the bytes that the part occupies in the completed archive. The upload ID is returned by the aws glacier initiate-multipart-upload command and can also be obtained by using aws glacier list-multipart-uploads.

For more information on multipart uploads to Amazon Glacier using the AWS CLI, see Using Amazon Glacier in the AWS CLI User Guide.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.