AWS
EntityTooSmall - Entity Too Small
Getting an **EntityTooSmall** error means a multipart upload part is smaller than the 5MB minimum—S3 requires each part (except the last) to be at least 5MB. This client-side error (4xx) happens when AWS validates multipart upload part sizes. Most common when multipart chunk size is set too small, but also appears when part sizes are less than 5MB (except last part), minimum part size is violated, or incorrect multipart chunk size is configured.
#Common Causes
- →Identity: IAM policy allows upload but part size invalid. Service Control Policy (SCP) enforces part size limits.
- →Network: VPC endpoint part size restrictions. API Gateway multipart size limits.
- →Limits: Multipart upload part too small (<5MB, except last). Part size less than 5MB minimum. Incorrect multipart chunk size. Part size below 5MB threshold.
✓Solutions
- 1Step 1: Diagnose - Check part sizes in multipart upload: Review multipart upload configuration. Check chunk size setting. Verify if parts are <5MB (except last).
- 2Step 2: Diagnose - Verify multipart upload requirements: S3 requires 5MB minimum per part (except last). Check if using multipart for small file (should use single upload).
- 3Step 3: Diagnose - Review upload code/configuration: Check chunk size setting. Verify multipart part size calculation. Check if last part is handled correctly.
- 4Step 4: Fix - Adjust chunk size to 5MB minimum: Set chunk size to at least 5MB: aws s3 cp FILE s3://BUCKET/KEY --expected-size SIZE (AWS CLI handles automatically). Or manually set part size in multipart upload.
- 5Step 5: Fix - Use single upload for small files: If file <5GB, use single upload: aws s3 cp FILE s3://BUCKET/KEY. Or combine small parts if using multipart. Ensure last part can be <5MB.
</>Code Examples
Check Part Sizes and Use Single Upload for Small Files
1#!/bin/bash
2FILE_PATH="small-file.txt"
3BUCKET_NAME="my-bucket"
4OBJECT_KEY="small-file.txt"
5
6# Check file size
7FILE_SIZE=$(stat -f%z "${FILE_PATH}" 2>/dev/null || stat -c%s "${FILE_PATH}" 2>/dev/null)
8MIN_PART_SIZE=5242880 # 5MB in bytes
9
10echo "=== File Size Check ==="
11echo "File size: ${FILE_SIZE} bytes"
12
13if [ ${FILE_SIZE} -lt ${MIN_PART_SIZE} ]; then
14 echo "✓ File <5MB - use single upload (not multipart)"
15 echo "\n=== Single Upload ==="
16 aws s3 cp ${FILE_PATH} s3://${BUCKET_NAME}/${OBJECT_KEY}
17else
18 echo "✓ File >=5MB - AWS CLI will handle multipart correctly"
19 echo "\n=== Multipart Upload (Automatic) ==="
20 aws s3 cp ${FILE_PATH} s3://${BUCKET_NAME}/${OBJECT_KEY}
21fi
22
23# Note: AWS CLI automatically ensures parts are >=5MB (except last)
24echo "\n=== Note ==="
25echo "AWS CLI automatically ensures:"
26echo "- Each part (except last) is >=5MB"
27echo "- Last part can be <5MB"
28echo "- No manual part size management needed"Verify Multipart Upload Part Sizes
1#!/bin/bash
2# If using manual multipart upload, verify part sizes
3BUCKET_NAME="my-bucket"
4OBJECT_KEY="file.zip"
5UPLOAD_ID="xxxxx" # From create-multipart-upload
6
7echo "=== Checking Multipart Upload Parts ==="
8MIN_PART_SIZE=5242880 # 5MB
9
10# List parts
11aws s3api list-parts \
12 --bucket ${BUCKET_NAME} \
13 --key ${OBJECT_KEY} \
14 --upload-id ${UPLOAD_ID} \
15 --query 'Parts[*].[PartNumber,Size]' \
16 --output table
17
18# Check if any part (except last) is <5MB
19echo "\n=== Validating Part Sizes ==="
20PARTS=$(aws s3api list-parts \
21 --bucket ${BUCKET_NAME} \
22 --key ${OBJECT_KEY} \
23 --upload-id ${UPLOAD_ID} \
24 --query 'Parts' \
25 --output json)
26
27TOTAL_PARTS=$(echo "${PARTS}" | jq 'length')
28LAST_PART_NUM=$(echo "${PARTS}" | jq '.[-1].PartNumber')
29
30echo "Total parts: ${TOTAL_PARTS}"
31echo "Last part number: ${LAST_PART_NUM}"
32
33# Check each part size
34echo "${PARTS}" | jq -r '.[] | "Part \(.PartNumber): \(.Size) bytes"' | while read line; do
35 PART_NUM=$(echo "${line}" | cut -d' ' -f2 | cut -d':' -f1)
36 PART_SIZE=$(echo "${line}" | cut -d' ' -f3)
37
38 if [ ${PART_NUM} -ne ${LAST_PART_NUM} ] && [ ${PART_SIZE} -lt ${MIN_PART_SIZE} ]; then
39 echo "✗ Part ${PART_NUM} is <5MB (except last part)"
40 else
41 echo "✓ Part ${PART_NUM} size OK"
42 fi
43done↗Related Errors
Provider Information
This error code is specific to AWS services. For more information, refer to the official AWS documentation.