I'd like to add file size validation to our signed urls, making sure the client uploads a file of exactly the size I signed it with. However, when I do this :
"conditions": [
    {"acl": "public-read"},
    .... ,
    ["content-length-range", 1024, 1024]
]
For small files, it works.
But a bit larger files, for example 25mb, it results in EntityTooSmall error.
It starts working only if I set the minimum to 0 like this :
["content-length-range", 0, 1024]
But I want to enforce a specific file size, and not a range.
Does S3 not support exact file size match?
EDIT : Here's the full code I compiled in Python :
# Create an S3 client
s3 = boto3.client(
    's3',
    aws_access_key_id="...",
    aws_secret_access_key="...",
    region_name="sfo3",
    endpoint_url="https://sfo3.digitaloceanspaces.com",
)
# Specify the bucket name
bucket_name = 'my_bucket'
# Specify the file name
file_name = 'SampleJPGImage_30mbmb.jpeg'
# Get the file size in bytes
file_size = os.path.getsize(file_name)
# Use the file size and content
print("File size:", file_size, "bytes") # Should be 30789588
# Specify the desired file size in bytes
file_size_min = file_size
file_size_max = file_size
# Sign the policy with your AWS secret key
signedPolicy = s3.generate_presigned_post(
    Bucket=bucket_name,
    Key=file_name,
    Fields={
        "acl": "public-read",
        "key": file_name,
    },
    Conditions=[
        {"acl": "public-read"},
        {"key": file_name},
        ["content-length-range", file_size_min, file_size_max]
    ],
    ExpiresIn=3600
)
# Use the signed policy to upload the file
with open(file_name, 'rb') as f:
    print()
    resp = requests.post(signedPolicy['url'], data=signedPolicy['fields'], files={'file': f})
    print(resp)
    print(resp.content)