s3: fix regression where PutObject fails with non-seekable readers

Commit a3e1312d accidentally replaced io.NopCloser(in) with a bare
io.Reader when assigning req.Body in uploadSinglepartPutObject.

rclone wraps upload readers in an accounting.Account for progress
tracking. When the AWS SDK calls Seek on the body, Account.Seek does
a type assert on the inner reader. With a bare io.Reader the type
is unexpected and causes:

  operation error S3: PutObject, serialization failed: internal error:
  Seek not implemented for io.nopCloser

With io.NopCloser(in) the type assert works correctly for both seekable
and non-seekable readers.

Restore io.NopCloser(in) to wrap the reader correctly in all cases.

Verified by running both before (regression confirmed) and after (fix
confirmed):
  go test ./backend/s3/... ./fs/operations/... -remote TestS3:
This commit is contained in:
Chris
2026-03-31 10:22:27 +01:00
committed by Nick Craig-Wood
parent da7a3d8d64
commit 434edba275
+1 -1
View File
@@ -4648,7 +4648,7 @@ func (o *Object) uploadSinglepartPutObject(ctx context.Context, req *s3.PutObjec
if err != nil {
return etag, lastModified, nil, err
}
req.Body = in
req.Body = io.NopCloser(in)
var options = []func(*s3.Options){}
if o.fs.opt.UseUnsignedPayload.Value {
options = append(options, s3.WithAPIOptions(