Disable "chunked" uploading by the GCS client for objects smaller than the chunk size. (#5835)

By disabling chunked uploading when the object size is less than the chunk size,
memory is not allocated unnecessarily.
master
wd256 6 years ago committed by minio-trusted
parent 75cc2ce9d8
commit 846f3e8f59
  1. 5
      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 {

Loading…
Cancel
Save