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
2020-12-17 18:11:14 +01:00
committed by GitHub
parent 970ddb424b
commit cffdb01279
3 changed files with 19 additions and 3 deletions

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)