Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase Storage Emulator: The given file does not have any download URLs #3451

Closed
vajahath opened this issue Jun 4, 2021 · 5 comments · Fixed by #3479
Closed

Firebase Storage Emulator: The given file does not have any download URLs #3451

vajahath opened this issue Jun 4, 2021 · 5 comments · Fixed by #3479

Comments

@vajahath
Copy link

vajahath commented Jun 4, 2021

Firebase says Firebase Storage: The given file does not have any download URLs when attempting to download.

Environment info

firebase-tools: 9.12.1
Platform: Windows

Test case

add-content.mjs

// use emulator
process.env.GCLOUD_PROJECT = "test-project";
process.env.FIREBASE_STORAGE_EMULATOR_HOST = "localhost:9199";

import admin from "firebase-admin";
admin.initializeApp({
  storageBucket: "default-bucket",
});
const storage = admin.storage().bucket();

const file = storage.file("app-data/test.json");

file
  .save(JSON.stringify({ stuffs: "stuffs" }))
  .then(() => console.log("wrote"))
  .catch((err) => console.error(err));  

read-content.html

<!DOCTYPE html>
<html>
  <head>
    <title>See</title>
  </head>
  <body>
    <script src="https://www.gstatic.com/firebasejs/8.6.4/firebase-app.js"></script>
    <script src="https://www.gstatic.com/firebasejs/8.6.4/firebase-storage.js"></script>
    <script>
      firebase.initializeApp({
        storageBucket: "default-bucket",
      });
      const storage = firebase.storage();
      storage.useEmulator("localhost", 9199);
      const contentRef = storage.ref("app-data/test.json");
      contentRef
        .getDownloadURL()
        .then((url) => console.log({ url }))
        .catch((err) => console.error(err));
    </script>
  </body>
</html>

Steps to reproduce

  • start storage emulator
  • run node add-content.mjs: you should see the message wrote
  • open read-content.html in chrome and check console: you should see the error message "Firebase Storage: The given file does not have any download URLs"
  • go to the emulator ui to check if the added file is there. (it is there. but you are unable to access it)

Expected behavior

You should be able to access it.

Actual behavior

Receiving error

Firebase Storage: The given file does not have any download URLs

My intuition may be incorrect but this randomly came to my mind: May be when I save the content, emulator is not creating a default access token. The reason behind this thought is when I go to the emulator and hit the "create new access token" button for this file, emulator creates a new access token. Then everything works as fine. The read-content.html file runs correctly.

@vajahath vajahath changed the title Firebase Storage: The given file does not have any download URLs Firebase Storage Emulator: The given file does not have any download URLs Jun 4, 2021
@abeisgoat abeisgoat self-assigned this Jun 9, 2021
@abeisgoat
Copy link
Contributor

This bug is a result of the fact that download tokens are not added when uploading through the Google Cloud API endpoints (which is in line with production), however the bug is that when getDownloadURL() is called via a Firebase endpoint, it should issue a token if none exist.

abeisgoat added a commit that referenced this issue Jun 9, 2021
@trullock
Copy link

trullock commented Jun 9, 2021

@abeisgoat is there a workaround unless that commit gets published very soon?

@trullock
Copy link

@samtstern woo thanks, do we know when this will ship?

@samtstern
Copy link
Contributor

@trullock we don't have a fixed release schedule but this will definitely be included in the next release. If you look at our history you can see that we normally do a release every week or so when there are changes pending!

@trullock
Copy link

great thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants