如何等到图像上传到 Ionic 2 中的 firebase 存储
How to wait until image uploaded to firebase storage in Ionic 2
我正在尝试使用加载程序等到图像上传到 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" 得到了解决方案
我正在尝试使用加载程序等到图像上传到 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" 得到了解决方案