1

I've used storage API in cloud function to upload some XML files as following:

await bucket.upload(filePath, {
        destination: fileName,
        resumable: true,
        metadata: {
            cacheControl: 'no-cache',
            metadata: {
                firebaseStorageDownloadTokens: uuidv4() //generate access token as I've found out on some other answers
            }
        }
    });

But then when I go to Firebase storage console to view the files uploaded, I'm unable to open them without manually creating new access token for them. I've tried generating download URL right after uploading as below

await bucket.file(fileName).getSignedUrl({
        action: 'read',
        expires: new Date().setDate(new Date().getDate() + 1) //expires after 24 hours
    });

but nothing changes. What should I do for now?

5
  • What do you mean by "I'm unable to open the file without manually creating an access token on Firebase storage UI"? Please edit the question to explain what you're doing when you "open the file". There should be enough information in the question so that anyone can follow the same steps to reproduce the issue. Commented Dec 10, 2020 at 7:34
  • @DougStevenson sorry for my bad English. What I'm trying to do is uploading files by cloud function, then go to Firebase console to view the uploaded contents. I see them, but I can't open, or download them if I don't create new access token. I've edited my question. Please tell me if there's still something uncleared. Commented Dec 10, 2020 at 7:40
  • It's a known issue that an image needs an access token before it can be loaded by the Firebase console. Commented Dec 10, 2020 at 8:06
  • @DougStevenson so currently there is no storage API to generate access token & attach to file before uploading? Commented Dec 10, 2020 at 8:44
  • There actually is a trick to generate such a token yourself. See stackoverflow.com/a/63138999 Commented Dec 10, 2020 at 16:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.