Cannot set metadata on a Google Storage Object from Node.js using Firebase Admin












0















I am writing a Firebase app and I need to change something in the backend running Node.js



admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: config.get("firebase.storage")
});


I get the bucket from initializing admin and am able to see the existing metadata from that file. Setting it doesn't work:



const myfile = {URL: "/users/1/demo.png"}; //this file exists

const bucket = admin.storage().bucket();
const [metadata] = await bucket.file(redeemable.URL).getMetadata();
console.log(metadata); //this works
if (!metadata.metadata.whitelist) metadata.metadata.whitelist = {};

metadata.metadata.whitelist[req.user.userId] = true;

await bucket.file(myfile.URL).setMetadata(metadata);


Shouldn't the firebase admin have access rights? I also don't get any error.










share|improve this question




















  • 1





    There's too much missing information here. What exactly doesn't work? Is there an error? What are the values of all the variables in here that we can't see? Try hardcoding values instead so we can see what you intend to do.

    – Doug Stevenson
    Jan 1 at 18:25











  • setMetadata does not work. bucket and file (the only variables) are correct I can see and console.log the file's metadata but when I set it, it doesn't. It is also missing from the official docs. No error

    – arisalexis
    Jan 2 at 13:59











  • Metadata does work. Without seeing all the exact values you're dealing with, there's nothing Stack Overflow can do do help. stackoverflow.com/help/mcve

    – Doug Stevenson
    Jan 2 at 17:20













  • I am very sorry to hear with authority that you are sure it works and that SO cannot help. Can you tell me what exact values do you need? The file string? I can never produce an example that works simply because it needs my access codes to my google storage server which cannot be published. Nothing else is missing. But it is missing from their official docs for Node.js and only mentions setting metadata from the gsutil tool. I did add more code to make it clearer.

    – arisalexis
    Jan 3 at 11:41













  • When you say console.log(metadata) works, what exactly does it do that meets your expectations? What exactly does the object look like that you're passing to setMetadata? Let's distill this code down to a single call to setMetadata to see if it receives the data you expect.

    – Doug Stevenson
    Jan 3 at 17:04


















0















I am writing a Firebase app and I need to change something in the backend running Node.js



admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: config.get("firebase.storage")
});


I get the bucket from initializing admin and am able to see the existing metadata from that file. Setting it doesn't work:



const myfile = {URL: "/users/1/demo.png"}; //this file exists

const bucket = admin.storage().bucket();
const [metadata] = await bucket.file(redeemable.URL).getMetadata();
console.log(metadata); //this works
if (!metadata.metadata.whitelist) metadata.metadata.whitelist = {};

metadata.metadata.whitelist[req.user.userId] = true;

await bucket.file(myfile.URL).setMetadata(metadata);


Shouldn't the firebase admin have access rights? I also don't get any error.










share|improve this question




















  • 1





    There's too much missing information here. What exactly doesn't work? Is there an error? What are the values of all the variables in here that we can't see? Try hardcoding values instead so we can see what you intend to do.

    – Doug Stevenson
    Jan 1 at 18:25











  • setMetadata does not work. bucket and file (the only variables) are correct I can see and console.log the file's metadata but when I set it, it doesn't. It is also missing from the official docs. No error

    – arisalexis
    Jan 2 at 13:59











  • Metadata does work. Without seeing all the exact values you're dealing with, there's nothing Stack Overflow can do do help. stackoverflow.com/help/mcve

    – Doug Stevenson
    Jan 2 at 17:20













  • I am very sorry to hear with authority that you are sure it works and that SO cannot help. Can you tell me what exact values do you need? The file string? I can never produce an example that works simply because it needs my access codes to my google storage server which cannot be published. Nothing else is missing. But it is missing from their official docs for Node.js and only mentions setting metadata from the gsutil tool. I did add more code to make it clearer.

    – arisalexis
    Jan 3 at 11:41













  • When you say console.log(metadata) works, what exactly does it do that meets your expectations? What exactly does the object look like that you're passing to setMetadata? Let's distill this code down to a single call to setMetadata to see if it receives the data you expect.

    – Doug Stevenson
    Jan 3 at 17:04
















0












0








0








I am writing a Firebase app and I need to change something in the backend running Node.js



admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: config.get("firebase.storage")
});


I get the bucket from initializing admin and am able to see the existing metadata from that file. Setting it doesn't work:



const myfile = {URL: "/users/1/demo.png"}; //this file exists

const bucket = admin.storage().bucket();
const [metadata] = await bucket.file(redeemable.URL).getMetadata();
console.log(metadata); //this works
if (!metadata.metadata.whitelist) metadata.metadata.whitelist = {};

metadata.metadata.whitelist[req.user.userId] = true;

await bucket.file(myfile.URL).setMetadata(metadata);


Shouldn't the firebase admin have access rights? I also don't get any error.










share|improve this question
















I am writing a Firebase app and I need to change something in the backend running Node.js



admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: config.get("firebase.storage")
});


I get the bucket from initializing admin and am able to see the existing metadata from that file. Setting it doesn't work:



const myfile = {URL: "/users/1/demo.png"}; //this file exists

const bucket = admin.storage().bucket();
const [metadata] = await bucket.file(redeemable.URL).getMetadata();
console.log(metadata); //this works
if (!metadata.metadata.whitelist) metadata.metadata.whitelist = {};

metadata.metadata.whitelist[req.user.userId] = true;

await bucket.file(myfile.URL).setMetadata(metadata);


Shouldn't the firebase admin have access rights? I also don't get any error.







firebase google-cloud-storage firebase-storage






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 11:42







arisalexis

















asked Jan 1 at 14:54









arisalexisarisalexis

1,0221329




1,0221329








  • 1





    There's too much missing information here. What exactly doesn't work? Is there an error? What are the values of all the variables in here that we can't see? Try hardcoding values instead so we can see what you intend to do.

    – Doug Stevenson
    Jan 1 at 18:25











  • setMetadata does not work. bucket and file (the only variables) are correct I can see and console.log the file's metadata but when I set it, it doesn't. It is also missing from the official docs. No error

    – arisalexis
    Jan 2 at 13:59











  • Metadata does work. Without seeing all the exact values you're dealing with, there's nothing Stack Overflow can do do help. stackoverflow.com/help/mcve

    – Doug Stevenson
    Jan 2 at 17:20













  • I am very sorry to hear with authority that you are sure it works and that SO cannot help. Can you tell me what exact values do you need? The file string? I can never produce an example that works simply because it needs my access codes to my google storage server which cannot be published. Nothing else is missing. But it is missing from their official docs for Node.js and only mentions setting metadata from the gsutil tool. I did add more code to make it clearer.

    – arisalexis
    Jan 3 at 11:41













  • When you say console.log(metadata) works, what exactly does it do that meets your expectations? What exactly does the object look like that you're passing to setMetadata? Let's distill this code down to a single call to setMetadata to see if it receives the data you expect.

    – Doug Stevenson
    Jan 3 at 17:04
















  • 1





    There's too much missing information here. What exactly doesn't work? Is there an error? What are the values of all the variables in here that we can't see? Try hardcoding values instead so we can see what you intend to do.

    – Doug Stevenson
    Jan 1 at 18:25











  • setMetadata does not work. bucket and file (the only variables) are correct I can see and console.log the file's metadata but when I set it, it doesn't. It is also missing from the official docs. No error

    – arisalexis
    Jan 2 at 13:59











  • Metadata does work. Without seeing all the exact values you're dealing with, there's nothing Stack Overflow can do do help. stackoverflow.com/help/mcve

    – Doug Stevenson
    Jan 2 at 17:20













  • I am very sorry to hear with authority that you are sure it works and that SO cannot help. Can you tell me what exact values do you need? The file string? I can never produce an example that works simply because it needs my access codes to my google storage server which cannot be published. Nothing else is missing. But it is missing from their official docs for Node.js and only mentions setting metadata from the gsutil tool. I did add more code to make it clearer.

    – arisalexis
    Jan 3 at 11:41













  • When you say console.log(metadata) works, what exactly does it do that meets your expectations? What exactly does the object look like that you're passing to setMetadata? Let's distill this code down to a single call to setMetadata to see if it receives the data you expect.

    – Doug Stevenson
    Jan 3 at 17:04










1




1





There's too much missing information here. What exactly doesn't work? Is there an error? What are the values of all the variables in here that we can't see? Try hardcoding values instead so we can see what you intend to do.

– Doug Stevenson
Jan 1 at 18:25





There's too much missing information here. What exactly doesn't work? Is there an error? What are the values of all the variables in here that we can't see? Try hardcoding values instead so we can see what you intend to do.

– Doug Stevenson
Jan 1 at 18:25













setMetadata does not work. bucket and file (the only variables) are correct I can see and console.log the file's metadata but when I set it, it doesn't. It is also missing from the official docs. No error

– arisalexis
Jan 2 at 13:59





setMetadata does not work. bucket and file (the only variables) are correct I can see and console.log the file's metadata but when I set it, it doesn't. It is also missing from the official docs. No error

– arisalexis
Jan 2 at 13:59













Metadata does work. Without seeing all the exact values you're dealing with, there's nothing Stack Overflow can do do help. stackoverflow.com/help/mcve

– Doug Stevenson
Jan 2 at 17:20







Metadata does work. Without seeing all the exact values you're dealing with, there's nothing Stack Overflow can do do help. stackoverflow.com/help/mcve

– Doug Stevenson
Jan 2 at 17:20















I am very sorry to hear with authority that you are sure it works and that SO cannot help. Can you tell me what exact values do you need? The file string? I can never produce an example that works simply because it needs my access codes to my google storage server which cannot be published. Nothing else is missing. But it is missing from their official docs for Node.js and only mentions setting metadata from the gsutil tool. I did add more code to make it clearer.

– arisalexis
Jan 3 at 11:41







I am very sorry to hear with authority that you are sure it works and that SO cannot help. Can you tell me what exact values do you need? The file string? I can never produce an example that works simply because it needs my access codes to my google storage server which cannot be published. Nothing else is missing. But it is missing from their official docs for Node.js and only mentions setting metadata from the gsutil tool. I did add more code to make it clearer.

– arisalexis
Jan 3 at 11:41















When you say console.log(metadata) works, what exactly does it do that meets your expectations? What exactly does the object look like that you're passing to setMetadata? Let's distill this code down to a single call to setMetadata to see if it receives the data you expect.

– Doug Stevenson
Jan 3 at 17:04







When you say console.log(metadata) works, what exactly does it do that meets your expectations? What exactly does the object look like that you're passing to setMetadata? Let's distill this code down to a single call to setMetadata to see if it receives the data you expect.

– Doug Stevenson
Jan 3 at 17:04














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53996442%2fcannot-set-metadata-on-a-google-storage-object-from-node-js-using-firebase-admin%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53996442%2fcannot-set-metadata-on-a-google-storage-object-from-node-js-using-firebase-admin%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules