GeezerVison is showing github.com — Allow setting of custom metadata · Issue #368 · googleapis/google-cloud-node
Allow setting of custom metadata #368Labels 🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged. DescriptionI 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#xgoogmeta
I've tried to take this approach to set custom metadata on objects created using gcloud-node as follows:
var stream = file.createWriteStream({
metadata: {
'x-goog-meta-entry-type': entry.type,
}
});
stream.once("finish", resolve);
stream.once("error", reject);
stream.end(buffer);
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? Activitystephenplusplus commented 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 :) ryanseys commented on Feb 2, 2015 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 metadata object within your original metadata object, like so:
fs.createReadStream('/my/local/file.png')
.pipe(image.createWriteStream({
metadata: {
contentType: 'image/jpeg',
metadata: {
customProperty: 'my cool photo'
}
}
}))
.on('error', function(err) {});dhermes commented on Feb 2, 2015 @ggoodman
Notice the docs you linked to are under the hierarchy
Cloud Storage API >XML API > API Reference > Headers and Query Parameters
So this header (I'm fairly certain) only applies to the XML API, not the JSON API. ryanseys commented on Feb 2, 2015 @dhermes Good catch, I did not notice this either. ggoodman commented on Feb 2, 2015 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. ggoodman commented on Feb 2, 2015 I have not tried @ryanseys recommendation, but if true, would obviate this issue and I'd be happy to close. What do you think? stephenplusplus commented on Feb 4, 2015 Yeah, I'll close this for now as metadata.metadata should work fine. If you try and that's not correct, just open it back up.
MetadataMetadata🚨This issue needs some love.api: storageIssues related to the Cloud Storage API.triage meI really want to be triaged. DevelopmentNo branches or pull requestsIssue actions
|