javascript - 从自定义服务订阅下载地址
问题描述
我正在使用 AngularFireStorage 构建上传图像服务。并且有问题。
没有人能告诉我订阅downloadurl的方法吗?这是我的服务:
这项服务可能会磨损?
uploadImage(image): Observable<any> {
const path = ...;
const fileRef = this.afStorage.ref(path);
const task = this.afStorage.upload(path, image);
return task.snapshotChanges().pipe(
finalize(() => {
return fileRef.getDownloadURL()
})
)
}
解决方案
const task = this.storage.upload(path, file);
const ref = this.storage.ref(path);
this.uploadPercent = task.percentageChanges();
console.log('Image uploaded!');
task.snapshotChanges().pipe(
finalize(() => {
this.downloadURL = ref.getDownloadURL()
this.downloadURL.subscribe(url => (this.image = url));
})
)
.subscribe();
当我意识到它过于复杂时,一直在阅读相同的文档。
推荐阅读
- iis - 如何仅将 IIS 脚本映射用于没有扩展名的路径
- python - 使用python unittest的相对导入错误
- ruby-on-rails - Rails Geocoder Gem - 访问 postcode_localities 的问题
- typescript - Typescript 编译器因省略和索引签名上的不同属性类型而失败
- r - 使用变量列表时如何使用或应该使用 case_when 来更改值
- python - 使用 Python filedialog askopenfilename() 方法打开文件时如何获取文件类型?
- python - 搜索一个词,在Python文本处理中修改整行
- azure - 在 Application Insights 中为 Worker Service 应用程序配置日志级别
- excel - 如何根据销售年份对相同产品的价值求和?
- excel - 如何处理新投资者,从基金中移除退出投资者