Immutable solution version
fix: MissingContentLength in boto3 version 1.36.1
Complete solution
boto3 1.36.0 enabled checksum calculation and validation by default, which many S3-compatible providers (DigitalOcean Spaces, OCI, Linode, Contabo, iDrive, Hitachi) do not support yet, producing `MissingContentLength` on PutObject. Fix it by opting out of the new defaults.
fix: MissingContentLength in boto3 version 1.36.1
boto3 1.36.0 enabled checksum calculation and validation by default, which many S3-compatible providers (DigitalOcean Spaces, OCI, Linode, Contabo, iDrive, Hitachi) do not support yet, producing MissingContentLength on PutObject. Fix it by opting out of the new defaults. Either set the environment variables:
AWSREQUESTCHECKSUMCALCULATION=WHENREQUIRED AWSRESPONSECHECKSUMVALIDATION=WHENREQUIRED
or pass a botocore Config:
from botocore.config import Config config = Config(requestchecksumcalculation='WHENREQUIRED', responsechecksumvalidation='WHENREQUIRED') s3 = boto3.resource('s3', config=config, endpointurl='YOURENDPOINT', awsaccesskeyid='YOURKEY', awssecretaccess_key [your value]
Use boto3 1.36.5 or newer, since an s3transfer bug that stopped these options applying to high-level S3 operations was fixed there. Downgrading to 1.35.99 also works but is the weaker option.
Context from the issue
gh:boto/boto3#4398: Issue boto/boto3#4398 (closed, 22 comments): ### Describe the bug
---
Description
I encountered an issue while using boto3 version 1.36.1 in conjunction with django-storages. When attempting to upload files to AWS S3, I received the following error:
An error occurred (MissingContentLength) when calling the PutObject operation: UnknownSteps to Reproduce
- Install
boto3version1.36.1anddjango-storages. - Configure Django to use S3 for file storage.
- Attempt to upload a file to S3.
Environment
boto3version:1.36.1django-storagesversion: django-storages==1.14.4- Django version:...
Evidence
Issue gh:boto/boto3#4398: the reporter asked: Issue boto/boto3#4398 (closed, 22 comments): ### Describe the bug
---
Description
I encountered an issue while using boto3 version 1.36.1 in conjunction with django-storages. When attempting to upload files to AWS S3, I received the following error:
An error occurred (MissingContentLength) when calling the PutObject operation: UnknownSteps to Reproduce
- Install
boto3version1.36.1anddjango-storages. - Configure Django to use S3 for file storage.
- Attempt to upload a file to S3.
Environment
boto3version:1.36.1django-storagesversion: django-storages==1.14.4- Django version:... The verified answer was: boto3 1.36.0 enabled checksum calculation and validation by default, which many S3-compatible providers (DigitalOcean Spaces, OCI, Linode, Contabo, iDrive, Hitachi) do not support yet, producing
MissingContentLengthon PutObject. Fix it by opting out of the new defaults. Either set the environment variables:
AWSREQUESTCHECKSUMCALCULATION=WHENREQUIRED AWSRESPONSECHECKSUMVALIDATION=WHENREQUIRED
or pass a botocore Config:
from botocore.config import Config config = Config(requestchecksumcalculation='WHENREQUIRED', responsechecksumvalidation='WHENREQUIRED') s3 = boto3.resource('s3', config=config, endpointurl='YOURENDPOINT', awsaccesskeyid='YOURKEY', awssecretaccess_key [your value]
Use boto3 1.36.5 or newer, since an s3transfer bug that stopped these options applying to high-level S3 operations was fixed there. Downgrading to 1.35.99 also works but is the weaker option. Evidence thread: https://github.com/boto/boto3/issues/4398
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_f01SI5xkYwkRzF7Wj57sfA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">fix: MissingContentLength in boto3 version 1.36.1 <span>— Vectle</span></a>