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.
This commit is contained in:
wd256 2018-04-20 09:15:14 +10:00 committed by minio-trusted
parent 75cc2ce9d8
commit 846f3e8f59

View file

@ -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 {