角度firebase上载图像

角度firebase上载图像,firebase,angular5,google-cloud-firestore,Firebase,Angular5,Google Cloud Firestore,我是Angular 5和firebase的初学者。 作为练习,我决定创建一个博客。 我的问题是我不能在firestore上传我的图片。当我上传到云存储并尝试检索下载链接时,它不会在firestore中注册 看看我的代码,给我一些建议 从'@angular/core'导入{Component,OnInit}; 从'src/app/shared/services/auth.service'导入{AuthService}; 从“rxjs/operators”导入{finalize}; 从“rxjs”

我是Angular 5和firebase的初学者。 作为练习,我决定创建一个博客。 我的问题是我不能在firestore上传我的图片。当我上传到云存储并尝试检索下载链接时,它不会在firestore中注册

看看我的代码,给我一些建议

从'@angular/core'导入{Component,OnInit};
从'src/app/shared/services/auth.service'导入{AuthService};
从“rxjs/operators”导入{finalize};
从“rxjs”导入{Observable};
从'@angular/fire/storage'导入{AngularFireStorage};
从'src/app/shared/services/posts.service'导入{PostsService};
从“ngx-toastr”导入{ToastrService};
从'@angular/Router'导入{Router};
@组成部分({
选择器:“应用程序帖子”,
templateUrl:'./posts.component.html',
样式URL:['./posts.component.scss']
})
导出类PostsComponent实现OnInit{
上传百分比:可见;
下载URL:可观察;
标题:字符串;
内容:字符串;
描述:字符串;
image:string=null;
构造函数(私有auth:AuthService,
私人祝酒词:祝酒服务,
私人邮政服务:邮政服务,
私人商店:AngularFireStorage,
专用路由器:路由器{}
恩戈尼尼特(){
}
createPost(){
//tslint:禁用下一行:首选常量
让数据={
content:this.content,
图像:这个图像,
description:this.description,
出版物:新日期(),
标题:this.title
};
this.router.navigate(['/admin']);
this.postService.create(数据);
this.title='';
这个。描述=“”;
这个。内容=“”;
这个.toast.success('Votre article aétépublié');
}
上载映像(事件){
//tslint:禁用下一行:首选常量
让file=event.target.files[0];
//tslint:禁用下一行:首选常量
让path=`posts/${file.name}`;
if(file.type.split('/')[0]!=='image'){
返回警报('Erreur,ce fichier n'est pas une image');
}否则{
//tslint:禁用下一行:首选常量
设ref=this.store.ref(路径);
//tslint:禁用下一行:首选常量
让task=this.store.upload(路径、文件);
this.uploadPercent=task.percentageChanges();
log('Image chargée avec success');
task.snapshotChanges().pipe(
完成(()=>{
this.downloadURL=ref.getDownloadURL();
this.downloadURL.subscribe(url=>{
console.log(url);
});
}
)
).subscribe();
}
}
}

乔伊斯爵士图像
{{uploadPercent}异步}
邮政税
描述
艺术伯爵酒店
海报文章

第一个问题写得很好-您可以通过包含控制台输出来帮助我们,这样我们就可以看到您的哪些消息出错(以及故障异常)。感谢您的关注。顺便说一句,在云存储中,上传是完美完成的,但当恢复下载链接以将其保存在firestore中时,在控制台firebase中,它会显示类似C:\fakepath\72e39b1d336\uuuuuCi\uW28\uS4\uJumia-Trust-2.jpg的内容,而不是下载链接,以便用户可以显示。