本文介绍了成功上传图片后,firebase snapshot.downloadURL未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有此代码,用于上传图像并获取其url,以便我可以将其保存在数据库中,该图像为base64格式,并且上传成功,如我在 console.log(snapshot); 输出,但是也通过检查我的firebase存储,快照的downloadUrl属性是未定义的,我不知道为什么.这不是应该的工作方式

I have this code in my app, that I use to upload an image and get its url so that i can save it in the database, the image is in base64 format and the upload is successfull as i can see in console.log(snapshot); output, and by checking also in my firebase storage however, the downloadUrl property of snapshot is undefined i dont know why. This is not the way it was supposed to work

storage.$putString(b64, 'data_url', {contentType:'image/jpg'}).$complete(function(snapshot) {
        console.log(snapshot);
        item.avatarUrl=snapshot.downloadURL;
        agents.$add(item).then(function(ref) {
        });

    });

推荐答案

使用 snapshot.ref.getDownloadURL()

这篇关于成功上传图片后,firebase snapshot.downloadURL未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:45