fix(file-store): disable default checksum calculation for MinIO#3
Merged
Conversation
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"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@aws-sdk/lib-storagedependencyPutObjectCommandwithUploadfromlib-storageforcopyFromStream()andcopyFromLocalFile()Problem
MinIO requires the
Content-LengthHTTP header for PUT requests. AWS SDK v3'sPutObjectCommanddoesn't properly handle streams of unknown size — it can't calculate the content length before sending the request.When uploading a stream (from
/media/uploador file read operations), the request fails with:Fix
The
Uploadclass from@aws-sdk/lib-storageproperly handles streaming uploads by:Content-LengthheadersUpdated methods:
copyFromStream(): uploads streams from/media/uploadcopyFromLocalFile(): uploads local filesTest plan
/media/uploadendpoint with MinIO as filestore — no "Content-Length" errorpnpm test🤖 Generated with Claude Code