2
votes

I'm using the upload-archive command in AWS-CLI in Windows PS to upload a zip archive to a Glacier vault and keep getting an 'InvalidParameterException: Invalid Content-Length' error. Not sure what parameter I'm missing.

My aws-cli command:

    aws glacier upload-archive --account-id - --vault-name sawsa.video.glacier --body saw-09-21-19.7z

Returns the following error:

An error occurred (InvalidParameterValueException) when calling the UploadArchive operation: Invalid ContentLength: 13769102233

I've ensured the account keys/secret and region are all saved in aws-cli config. I can list/read content of the vault without any problem. I'm providing the full account ID in my command, but am using the '-' here, for posting code sample.

2

2 Answers

3
votes

Multipart upload is required when the object size you are uploading is greater than 5 GBs.

As stated in the AWS documentation for S3:

Depending on the size of the data you are uploading, Amazon S3 offers the following options:

Upload objects in a single operation—With a single PUT operation, you can upload objects up to 5 GB in size.

Upload objects in parts—Using the multipart upload API, you can upload large objects, up to 5 TB.

Example:

Load the first part:

$ aws glacier initiate-multipart-upload --account-id - --part-size 1048576 --vault-name my-vault --archive-description "multipart upload test"


This command outputs an upload ID when successful. Use the upload ID when uploading each part of your archive with aws glacier upload-multipart-part as shown next:

Load the rest assuming the returned upload ID is 19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ (repeat as many times as necessary to consume the object):

aws glacier upload-multipart-part --body saw-09-21-19-part1.7z --range 'bytes 0-1048575/*' --account-id - --vault-name my-vault --upload-id 19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ

Here is step-by-step information on how to do it with the CLI:
https://docs.aws.amazon.com/cli/latest/userguide/cli-services-glacier.html

See here for even more information:
https://docs.aws.amazon.com/AmazonS3/latest/dev/UploadingObjects.html
https://docs.aws.amazon.com/cli/latest/reference/glacier/upload-multipart-part.html

0
votes

According to the CLI docs it looks like you must provide a SHA256 treehash. https://docs.aws.amazon.com/cli/latest/reference/glacier/upload-archive.html (see paragraph 3)

If I'm reading this correctly, it looks like your file is about 13GB. Even though upload-archive should work with files up to 40GB, you might also want to try using upload-multi-part command. https://docs.aws.amazon.com/cli/latest/reference/glacier/upload-multipart-part.html

As a side note I also noticed that the corresponding AWS Rest API endpoint/command for glacier seems to require Content-Length as a header parameter, but I don't see it mentioned in the CLI docs. https://docs.aws.amazon.com/amazonglacier/latest/dev/api-archive-post.html