fix(s3): sign content type for direct uploads - #3152
Open
mumingluan wants to merge 1 commit into
Open
mumingluan wants to merge 1 commit into
mumingluan wants to merge 1 commit into
Conversation
- Include the inferred MIME type in presigned PutObject requests - Return the signed Content-Type header for frontend uploads Co-authored-by: Codex <267193182+codex@users.noreply.github.com>
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 / 摘要
S3 direct uploads can return
403 AccessDeniedon Ceph RGW when the browser sends aContent-Typeheader that is absent from the presigned URL's signed headers. The current driver signs onlyhost.Determine the MIME type using
utils.GetMimeType, include it in the presignedPutObjectrequest, and return the sameContent-TypethroughHttpDirectUploadInfo.Headers. The frontend already applies these headers, so the uploaded MIME type matches the signature. Unknown extensions useapplication/octet-stream.The existing optional
headersresponse field is now populated withContent-Typefor S3 direct uploads.Testing / 测试
go test ./drivers/s3 -count=1passed on Windows with Go 1.27.1.git diff --checkpassed.403 AccessDeniedfor a 1 KiB upload carryingContent-Type.200 OK).HeadObjectconfirmed the stored sizes; temporary objects were deleted.Checklist / 检查清单
gofmt.AI Disclosure / AI 使用声明
Co-authored-byattribution.