Error: "(InvalidArgument) when calling the PutObject operation: The value provided in request header Content-Length is not valid" when uploading files to an S3 bucket with AWS CLI
search cancel

Error: "(InvalidArgument) when calling the PutObject operation: The value provided in request header Content-Length is not valid" when uploading files to an S3 bucket with AWS CLI

book

Article ID: 429229

calendar_today

Updated On:

Products

VMware Cloud Director

Issue/Introduction

  • Using an AWS CLI command to upload a file to a bucket in VMware Cloud Director Object Storage Extension (OSE), for example:

    aws s3 cp <file_name> s3://<bucket_name>/

  • Upload attempt with an AWS CLI command fails with an error of the form:

    upload failed: ./<file_name> to s3://<bucket_name>/<file_name> An error occurred (InvalidArgument) when calling the PutObject operation: The value provided in request header Content-Length is not valid.

  • Uploading a file to a bucket through the Object Storage plugin in the Cloud Director Tenant portal succeeds.

Environment

  • VMware Cloud Director Object Storage Extension 3.1.0.x
  • VMware Cloud Director 10.6.1.x

Cause

This issue occurs when the PUT request sent by the client to OSE does not include a Content-Length header.

Resolution

This issue is under review by VMware Cloud Director Object Storage Extension Engineering.

Subscribe to this knowledge article to get updates on this issue.

Workaround

To workaround the issue uploading with AWS CLI, the request_checksum_calculation configuration setting can be set to when_required in AWS CLI.
For more information on this configuration setting, see the AWS CLI user guide here, Configuration and credential file settings in the AWS CLI, Supported config file settings.

Disclaimer: Broadcom is not responsible for the reliability of any data, opinions, advice, or statements made on third-party websites. Inclusion of such links does not imply that Broadcom endorses, recommends, or accepts any responsibility for the content of such sites.

Example steps could be as follows:

  1. Log into the Cloud Director Tenant portal as the user who will be uploading a file to the bucket.
  2. Open Object Storage > Security Credentials > User Credentials and click the Key Pair button to retrieve the user's Access Key and Secret Key.
  3. On the client where AWS CLI is installed, create a profile using the Access Key and Secret Key retrieved in step 2 above. For example:

    aws configure --profile <profile_name>

    AWS Access Key ID [****************####]: <access_key>
    AWS Secret Access Key [****************####]: <secret_key>
    Default region name [None]:
    Default output format [None]:

  4. Set the request_checksum_calculation configuration setting to when_required for the profile:

    aws configure set request_checksum_calculation when_required --profile <profile_name>

  5. Attempt the upload using this profile and it should succeed as a Content-Length header will be sent:

    aws s3 cp <file_name> s3://<bucket_name>/ --profile <profile_name>