Firebase 存储 downloadURL 文件结构

Piu*_*ojo 5 firebase firebase-hosting firebase-storage

所以我使用 firebase 存储来上传我的网站文件。以下是目录结构的示例:

\n\n
Project\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.html\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 css\n\xe2\x94\x82   \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 style.css\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 js\n    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 mainScript.js\n
Run Code Online (Sandbox Code Playgroud)\n\n

因此,我以这种结构将这些文件上传到 firebase,但我注意到返回的 downloadURL 在保留这种结构方面不是很友好。

\n\n

例如,当我将 iframe 的 src 设置为 index.html.. 的 downloadURL 时,iframe 页面缺少样式和 mainScript 文件。

\n\n

这是 downloadURL 查找 index.html 的方式:

\n\n

https://firebasestorage.googleapis.com/v0/b/App_ID.appspot.com/o/index.html?alt=media&token=some_uid

\n\n

这是 downloadURL 查找 style.css 的方式:

\n\n

https://firebasestorage.googleapis.com/v0/b/App_ID.appspot.com/o/css%2Fstyle.css?alt=media&token=some_uid \netc..

\n\n

当然,index.html 文件正在寻找 style.css 文件:

\n\n

https://firebasestorage.googleapis.com/v0/b/App_ID.appspot.com/o/css/style.css

\n\n

但结果是 404。

\n\n

有办法解决这个问题吗?

\n\n
\n

PS,当然我不想强迫用户更改文件中的网址......

\n
\n

vid*_*uch 1

不要使用存储来保存您的网站文件!使用 Firebase 托管...Firebase 存储设计用于存储上传/下载文件(图像、音频等)

https://firebase.google.com/docs/hosting/

  • 我的目的不是存储我自己的网站文件..我试图允许我网站的用户上传他们自己的网站(当然没有服务器脚本..使用 Firebase api 会模糊界限,但可能你明白我的意思)基本上,我对 Firebase Storage 的假设是它会像 Firebase Hosting 一样,只不过我们可以以编程方式访问存储,而不仅仅是通过 CLI 访问存储。 (6认同)