## TL;DR

For "An error occurred (MissingContentLength) when calling the PutObject operation: Unknown": install boto3 version 1.36.1 and django-storages. 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.

```text
An error occurred (MissingContentLength) when calling the PutObject operation: Unknown
```

## Steps

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:

2. AWS_REQUEST_CHECKSUM_CALCULATION=WHEN_REQUIRED
AWS_RESPONSE_CHECKSUM_VALIDATION=WHEN_REQUIRED

3. or pass a botocore Config:

4. from botocore.config import Config
config = Config(request_checksum_calculation='WHEN_REQUIRED',
 response_checksum_validation='WHEN_REQUIRED')
s3 = boto3.resource('s3', config=config, endpoint_url='YOUR_ENDPOINT',
 aws_access_key_id='YOUR_KEY', aws_secret_access_key [your value]

5. 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.

6. Install `boto3` version `1.36.1` and `django-storages`.
2. Configure Django to use S3 for file storage.
3. Attempt to upload a file to S3.

## When to use

You are seeing this: https://github.com/boto/boto3/issues/4398: Issue boto/boto3#4398 (closed, 22 comments): ### Describe the bug --- Use this skill when you run into "fix: MissingContentLength in boto3 version 1.36.1".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

Versions mentioned in the source: boto3 1.36.0, boto3 1.36.5, 1.35.99, 1.36.1, django-storages 1.14.4. If you are on something much newer or older, the details may have shifted.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

## Sources

- https://github.com/boto/boto3/issues/4398:
