diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2025-06-19 22:58:10 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-19 22:58:10 -0700 |
| commit | a72c442945af575cc2a94d1aa9867a4710ded02e (patch) | |
| tree | 8796346b475a0aa05c4eeb23f6a0b17dad0fc04f /weed/s3api/s3api_put_object_helper.go | |
| parent | f52134f9a1fde38214bc9f468798c3c979c136c3 (diff) | |
| download | seaweedfs-a72c442945af575cc2a94d1aa9867a4710ded02e.tar.xz seaweedfs-a72c442945af575cc2a94d1aa9867a4710ded02e.zip | |
Fix chunked data reading if iam not enabled (#6898)
* fix chunked data reading if iam not enabled
* add unit test
Diffstat (limited to 'weed/s3api/s3api_put_object_helper.go')
| -rw-r--r-- | weed/s3api/s3api_put_object_helper.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/weed/s3api/s3api_put_object_helper.go b/weed/s3api/s3api_put_object_helper.go index f1348aa0e..626e1c22d 100644 --- a/weed/s3api/s3api_put_object_helper.go +++ b/weed/s3api/s3api_put_object_helper.go @@ -7,6 +7,11 @@ import ( "github.com/seaweedfs/seaweedfs/weed/s3api/s3err" ) +// getRequestDataReader returns the appropriate reader for the request body. +// When IAM is disabled, it still processes chunked transfer encoding for +// authTypeStreamingUnsigned to strip checksum headers and extract the actual data. +// This fixes issues where chunked data with checksums would be stored incorrectly +// when IAM is not enabled. func getRequestDataReader(s3a *S3ApiServer, r *http.Request) (io.ReadCloser, s3err.ErrorCode) { var s3ErrCode s3err.ErrorCode dataReader := r.Body @@ -21,8 +26,13 @@ func getRequestDataReader(s3a *S3ApiServer, r *http.Request) (io.ReadCloser, s3e _, s3ErrCode = s3a.iam.reqSignatureV4Verify(r) } } else { - if authTypeStreamingSigned == rAuthType { + switch rAuthType { + case authTypeStreamingSigned: s3ErrCode = s3err.ErrAuthNotSetup + case authTypeStreamingUnsigned: + // Even when IAM is disabled, we still need to handle chunked transfer encoding + // to strip checksum headers and process the data correctly + dataReader, s3ErrCode = s3a.iam.newChunkedReader(r) } } |
