Repository navigation
Allow setting of custom metadata #368
Description
Activity
- addedapi: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.
on Feb 2, 2015 Thanks for catching this! I'm talking to myself about a good solution over in #373 - feel free to chime in :)
Hey @ggoodman nice issue! This raises an entirely different question as well and that is: "Do we have a way to specify custom headers?" I'm going to guess no. But I think that's okay, because doing that is beyond the scope of this library. That being said, I think we do support custom metadata already although it's poorly documented. What you need to do is a set a
metadataobject within your originalmetadataobject, like so:fs.createReadStream('/my/local/file.png') .pipe(image.createWriteStream({ metadata: { contentType: 'image/jpeg', metadata: { customProperty: 'my cool photo' } } })) .on('error', function(err) {});
Reacted by Mark LewisNotice the docs you linked to are under the hierarchy
Cloud Storage API >XML API > API Reference > Headers and Query ParametersSo this header (I'm fairly certain) only applies to the XML API, not the JSON API.
@dhermes Good catch, I did not notice this either.
Hi @dhermes good catch. I guess I wasn't able to identify the correct api that backs this project. Perhaps that is an issue itself. I consider myself a passable code / documentation spelunker and wasn't able to track this down.
My path there was:
- Have a need for custom metadata
- Identify that the underlying service supports custom metadata
- Search left and right for anything cloud storage and custom metadata
I think that a simple fix would be to clarify that custom metadata is settable via the metadata of the metadata in the documents. At the same time, it would be nice to describe how said custom metadata will be returned via the
getMetadata()call.Thanks for taking a look at this so quickly, @dhermes and @ryanseys.
I have not tried @ryanseys recommendation, but if true, would obviate this issue and I'd be happy to close. What do you think?
Yeah, I'll close this for now as
metadata.metadatashould work fine. If you try and that's not correct, just open it back up.- addedtriage meI really want to be triaged.I really want to be triaged.🚨This issue needs some love.This issue needs some love.
on Apr 6, 2020 - added a commit that references this issue
on Aug 22, 2022 32 remaining items
- added a commit that references this issue
on Feb 26, 2026 - added a commit that references this issue
on Mar 5, 2026 - added 2 commits that reference this issue
on Mar 5, 2026 - added a commit that references this issue
on Mar 18, 2026 - added 2 commits that reference this issue
on Mar 23, 2026 - added a commit that references this issue
on Mar 27, 2026 - added a commit that references this issue
on May 5, 2026
I understand from the documents for cloud storage that it is possible to set custom metadata with the
x-goog-meta-prefix as specified here: https://cloud.google.com/storage/docs/reference-headers#xgoogmetaI've tried to take this approach to set custom metadata on objects created using
gcloud-nodeas follows:However, no objects created using that approach have the custom metadata reflected when requested via
file.getMetadata()nor when viewed via the online storage browser.How can one set custom metadata using
gcloud-node?