In the implementation of the object rewrite operation, metadata provided in the request is merged(-ish) with metadata from the source object to produce the final metadata set.
|
// Only supplied metadata overwrites the new object's metadata |
|
if len(metadata.Metadata) == 0 { |
|
metadata.Metadata = obj.Metadata |
|
} |
|
if metadata.ContentType == "" { |
|
metadata.ContentType = obj.ContentType |
|
} |
|
if metadata.ContentEncoding == "" { |
|
metadata.ContentEncoding = obj.ContentEncoding |
|
} |
|
if metadata.ContentDisposition == "" { |
|
metadata.ContentDisposition = obj.ContentDisposition |
|
} |
|
if metadata.ContentLanguage == "" { |
|
metadata.ContentLanguage = obj.ContentLanguage |
|
} |
|
if metadata.CacheControl == "" { |
|
metadata.CacheControl = obj.CacheControl |
|
} |
|
|
|
dstBucket := vars["destinationBucket"] |
|
if _, err := s.backend.GetBucket(dstBucket); err != nil { |
|
return jsonResponse{status: http.StatusNotFound} |
|
} |
|
newObject := StreamingObject{ |
|
ObjectAttrs: ObjectAttrs{ |
|
BucketName: dstBucket, |
|
Name: vars["destinationObject"], |
|
ACL: obj.ACL, |
|
ContentType: metadata.ContentType, |
|
ContentEncoding: metadata.ContentEncoding, |
|
ContentDisposition: metadata.ContentDisposition, |
|
ContentLanguage: metadata.ContentLanguage, |
|
CacheControl: metadata.CacheControl, |
|
Metadata: metadata.Metadata, |
|
}, |
|
Content: obj.Content, |
|
} |
However, this differs from how the operation is described (and anecdotally, how I've seen it behave):
If the request body is empty, editable metadata from the source object is applied to the destination object [...]
The corollary to this statement is that if the request body is not empty, then the editable metadata is not copied - which is the behaviour I have observed with real GCS. So, setting any editable metadata fields should cause the request to be the sole source of the editable metadata fields (as defined here).
In the implementation of the object rewrite operation, metadata provided in the request is merged(-ish) with metadata from the source object to produce the final metadata set.
fake-gcs-server/fakestorage/object.go
Lines 958 to 995 in 7503535
However, this differs from how the operation is described (and anecdotally, how I've seen it behave):
The corollary to this statement is that if the request body is not empty, then the editable metadata is not copied - which is the behaviour I have observed with real GCS. So, setting any editable metadata fields should cause the request to be the sole source of the editable metadata fields (as defined here).