【问题标题】:task.ref.getDownloadURL() throws "storage/object-not-found" errortask.ref.getDownloadURL() 抛出“storage/object-not-found”错误
【发布时间】:2018-12-29 00:58:48
【问题描述】:

当我尝试将文件上传到存储服务器时,它上传正常。但是当我订阅快照更改以获取下载 URL 时,它会引发错误。

这是我的代码:

    const fileForUpload = this.filesForUpload[0];
    this.afStorage
        .upload(
            fileForUpload.path,
            fileForUpload.file,
            fileForUpload.metadata
        )
        .snapshotChanges()
        .subscribe(task => {
            const downloadUrl = task.ref.getDownloadURL(); // throws error!
        });

这是错误信息:

Firebase 存储:对象 'reddit/1532105412851_node_js_hexagon-wallpaper-1920x1080.jpg' 确实 不存在。

如果您想了解有关错误消息的更多详细信息,请查看以下屏幕截图:

上面写着 reddit/,因为我正在重新创建 reddit.com 以进行练习。

当我查看我在 firebase 上的存储时,我看到文件上传正常。

【问题讨论】:

    标签: firebase firebase-storage angularfire2


    【解决方案1】:

    使用回调函数

    this.storage.ref(path).putString(this.image, 'data_url').then(data => {
          //data in this case contains the download ref
         console.log(data) //this will help you see the response
    }); 
    

    【讨论】:

    • 谢谢。似乎.subscribe() 不起作用,但.then() 起作用。
    猜你喜欢
    • 2022-06-16
    • 1970-01-01
    • 2020-04-12
    • 2012-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-18
    • 1970-01-01
    相关资源
    最近更新 更多