Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何等待图像上载到Ionic 2中的firebase存储_Firebase_Upload_Ionic2_Loading_Wait - Fatal编程技术网

如何等待图像上载到Ionic 2中的firebase存储

如何等待图像上载到Ionic 2中的firebase存储,firebase,upload,ionic2,loading,wait,Firebase,Upload,Ionic2,Loading,Wait,我试图等到使用loader将图像上传到firebase存储上,但效果不好 我这样写我的代码,但我不知道我的错误在哪里,为什么在上传过程前会显示警报 private uploadPhoto(): void { let loader = this.loadingCtrl.create({ content: "" }) loader.present().then(_=>{ this.myPhotosRef.child(this.genera

我试图等到使用loader将图像上传到firebase存储上,但效果不好

我这样写我的代码,但我不知道我的错误在哪里,为什么在上传过程前会显示警报

private uploadPhoto(): void {
    let loader = this.loadingCtrl.create({
        content: ""
    })
    loader.present().then(_=>{
        this.myPhotosRef.child(this.generateUUID()).child('myPhoto.JPEG')
        .putString(this.myPhoto, 'base64', { contentType: 'image/JPEG' })
        .then((savedPicture) => {
            this.myPhotoURL = savedPicture.downloadURL;
            this.afd.list('/Images/').push({
                nID: this.appService.id,
                url: this.myPhotoURL,
                date: new Date().toISOString()
            });
        });
    }).then(_=>{
        alert("image uploaded and stored in database");
        loader.dismiss();
    })
}

我通过在“this.myPhotosRef.child…”之前添加“return”得到了解决方案。

首先添加一个return,然后
返回这个.myPhotosRef.child…”
@mohamadrabee是的,我忘了写return。。谢谢穆罕默德