我正在使用 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();
在这方面工作了一段时间阅读相同的 Documentation ,当我意识到它过于复杂时。
关于javascript - 从自定义服务订阅 downloadurl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50541986/