实时 firebase 上传 zip URL

问题描述

enter image description here

我需要这种类型的 URL(我在图片显示)我在实时 firebase 数据库中的文件。我无法编写 JavaScript 代码

解决方法

如果您使用脚本上传,则需要从参考中获取下载 URL。这可以通过以下方式完成(使用 javascript 的 Firebase 网络方法)

// Put the file into storage
var uploadTask = storageRef.child('images/rivers.zip').put(file)
// catch the snapshot of storage upload and get download URL
.then(snapshot => snapshot.ref.getDownloadURL())
// send download URL to realtime database
.then((downloadURL) => {
    firebase.database().ref('files/' + FileID + '/url'.set(downloadURL);
    })
.catch(console.log());