2017-08-12 92 views
0

我想等到使用裝載機上載火力存儲圖像,但它不能正常工作如何要等到圖像上傳到火力存儲在離子2

我寫了我這樣的代碼,但我不不知道我的錯誤在哪裏,以及爲什麼在上傳過程中顯示警報。

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(); 
    }) 
} 
+0

添加在第一回,然後返回'...... this.myPhotosRef.child ' –

+0

@mohamadrabee是的,我忘了寫回去..謝謝mohamad –

回答

1

我加入「重返」得到了解決之前「this.myPhotosRef.child ......」

相關問題