docs: Clarify whether setMetadata is replacing existing metadata or updating only specified fields #2513
Labels
api: storage
Issues related to the googleapis/nodejs-storage API.
priority: p3
Desirable enhancement or fix. May not be included in next release.
type: question
Request for information or clarification. Not an issue.
From the NodeJS documentation, it is not clear enough whether calling
file.setMetadata({contentType: 'image/png'})
would remove existing metadata fields on the field (as they are not specified) or would only change the content type.To understand this, one must dig deeply into the NodeJS SDK to understand the exact behaviour and cross-reference it with the Cloud Storage API.
From my understanding,
setMetadata
is using PATCH, so any existing metadata would stay the same, correct?--
Could we please update the documentation to make this clearer?
e.g.
Set the metadata of the object. Uses PATCH method, meaning it only modifies passed fields and leaves unspecified fields unchanged.
nodejs-storage/src/nodejs-common/service-object.ts
Lines 477 to 485 in 57b28f1
And also mirror those function documentation to the
File
class method (as otherwise, the documentation will not be surfaced on the SDK API documentation page)See: https://cloud.google.com/nodejs/docs/reference/storage/latest/storage/file#_google_cloud_storage_File_setMetadata_member_1_
The text was updated successfully, but these errors were encountered: