in internal/storage/bucket_handle.go [392:444]
func (bh *bucketHandle) UpdateObject(ctx context.Context, req *gcs.UpdateObjectRequest) (o *gcs.Object, err error) {
defer func() {
err = gcs.GetGCSError(err)
}()
obj := bh.bucket.Object(req.Name)
if req.Generation != 0 {
obj = obj.Generation(req.Generation)
}
if req.MetaGenerationPrecondition != nil {
obj = obj.If(storage.Conditions{MetagenerationMatch: *req.MetaGenerationPrecondition})
}
updateQuery := storage.ObjectAttrsToUpdate{}
if req.ContentType != nil {
updateQuery.ContentType = *req.ContentType
}
if req.ContentEncoding != nil {
updateQuery.ContentEncoding = *req.ContentEncoding
}
if req.ContentLanguage != nil {
updateQuery.ContentLanguage = *req.ContentLanguage
}
if req.CacheControl != nil {
updateQuery.CacheControl = *req.CacheControl
}
if req.Metadata != nil {
updateQuery.Metadata = make(map[string]string)
for key, element := range req.Metadata {
if element != nil {
updateQuery.Metadata[key] = *element
}
}
}
attrs, err := obj.Update(ctx, updateQuery)
if err != nil {
err = fmt.Errorf("error in updating object: %w", err)
return
}
// Converting objAttrs to type *Object
o = storageutil.ObjectAttrsToBucketObject(attrs)
return
}