diff --git a/cmd/gateway/gcs/gateway-gcs.go b/cmd/gateway/gcs/gateway-gcs.go index c16743a13..e64f99dd9 100644 --- a/cmd/gateway/gcs/gateway-gcs.go +++ b/cmd/gateway/gcs/gateway-gcs.go @@ -839,6 +839,11 @@ func (l *gcsGateway) PutObject(ctx context.Context, bucket string, key string, d object := l.client.Bucket(bucket).Object(key) w := object.NewWriter(l.ctx) + // Disable "chunked" uploading in GCS client if the size of the data to be uploaded is below + // the current chunk-size of the writer. This avoids an unnecessary memory allocation. + if data.Size() < int64(w.ChunkSize) { + w.ChunkSize = 0 + } applyMetadataToGCSAttrs(metadata, &w.ObjectAttrs) if _, err := io.Copy(w, data); err != nil {