我试图等到图像通过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();
})
}