azure/s3 gateways: Pass ETag during GET call to avoid data corruption (#11024)

Both Azure & S3 gateways call for object information before returning
the stream of the object, however, the object content/length could be
modified meanwhile, which means it can return a corrupted object.

Use ETag to ensure that the object was not modified during the GET call
This commit is contained in:
Anis Elleuch authored and GitHub committed 2020-12-17 09:11:14 -08:00
1 parent 970ddb424b
commit cffdb01279
3 files changed
+19 -3

No files matched your search

+5
View File
@@ -431,6 +431,11 @@ func (l *s3Objects) GetObject(ctx context.Context, bucket string, key string, st
return minio.ErrorRespToObjectError(err, bucket, key)
}
}
if etag != "" {
opts.SetMatchETag(etag)
}
object, _, _, err := l.Client.GetObject(ctx, bucket, key, opts)
if err != nil {
return minio.ErrorRespToObjectError(err, bucket, key)