Skip to content

fix(file-store): disable default checksum calculation for MinIO#3

Merged
saby1101 merged 2 commits into
mainfrom
fix/minio-checksum-header
Apr 9, 2026
Merged

fix(file-store): disable default checksum calculation for MinIO#3
saby1101 merged 2 commits into
mainfrom
fix/minio-checksum-header

Conversation

@shivamora27

@shivamora27 shivamora27 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Added @aws-sdk/lib-storage dependency
  • Replaced PutObjectCommand with Upload from lib-storage for copyFromStream() and copyFromLocalFile()

Problem

MinIO requires the Content-Length HTTP header for PUT requests. AWS SDK v3's PutObjectCommand doesn't properly handle streams of unknown size — it can't calculate the content length before sending the request.

When uploading a stream (from /media/upload or file read operations), the request fails with:

  • 411 Length Required: MinIO rejects the request (no Content-Length header)
  • "You must provide the Content-Length HTTP header": AWS SDK error

Fix

The Upload class from @aws-sdk/lib-storage properly handles streaming uploads by:

  • Automatically handling multipart uploads
  • Calculating proper Content-Length headers
  • Buffering when needed for small files
  • Working across S3, MinIO, GCS, and other S3-compatible services

Updated methods:

  • copyFromStream(): uploads streams from /media/upload
  • copyFromLocalFile(): uploads local files

Test plan

  • Upload a file via /media/upload endpoint with MinIO as filestore — no "Content-Length" error
  • Upload a local file via filestore API
  • Confirm existing tests pass: pnpm test

🤖 Generated with Claude Code

shivamora27 and others added 2 commits April 9, 2026 13:49
AWS SDK v3 (>=3.421) changed the default to always compute checksums on
uploads. When streaming without a known ContentLength, it tries to set
x-amz-decoded-content-length to undefined, crashing before the request
reaches MinIO.

Set requestChecksumCalculation and responseChecksumValidation to
WHEN_REQUIRED on the MinIO S3Client so checksums are only computed when
the S3 protocol actually requires them.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AWS SDK v3's PutObjectCommand doesn't handle streams without known
ContentLength properly. MinIO requires the Content-Length header.

Replace PutObjectCommand with Upload from @aws-sdk/lib-storage for:
- copyFromStream(): streams of unknown size
- copyFromLocalFile(): file read streams

Upload handles multipart uploads, calculates proper headers, and works
across S3, MinIO, and GCS seamlessly. Also works for AWS S3 and Azure.

Fixes:
- "You must provide the Content-Length HTTP header" (MinIO)
- "Invalid value undefined for header x-amz-decoded-content-length"
@saby1101 saby1101 merged commit 4463d02 into main Apr 9, 2026
1 check passed
@saby1101 saby1101 deleted the fix/minio-checksum-header branch April 9, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants