【发布时间】:2018-11-12 14:46:33
【问题描述】:
使用来自Example Usage 的示例代码。我能够成功上传图像文件并显示它的链接。但是,我想在上传后立即在 img 标签中显示图像,而不是链接。我将如何做到这一点?我尝试过这样的事情无济于事:
profileUrl: Observable<string | null>;
....
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 = this.profileUrl = ref.getDownloadURL())
)
.subscribe();
在我的模板文件中:
<img [src]="profileUrl | async" />
所有这些都来自示例,但我需要将 Example Usage 与 Download Files 部分结合起来。
【问题讨论】:
标签: javascript firebase-storage angularfire2