【发布时间】:2019-03-25 01:15:27
【问题描述】:
没有错误我只想检查回调是否有效。但事实并非如此。 这是针对 AngularFireStorage 的,上传图片后,我打算获取 downloadURL,但问题是,可观察的管道不起作用,我也尝试使用 { tap } 但没有运气。
这是代码
const path = `hospital/${new Date().getTime()}_${file.name}`;
const customMetadata = { app : 'PROV-H meta'};
const ref = this.storage.ref(path);
this.task = ref.put(file,{customMetadata});
this.percentage = this.task.percentageChanges();
this.snapshot = this.task.snapshotChanges().pipe(
finalize(()=>{
console.log("percent finalize");
})
);
这是来自控制台的日志。
XHR finished loading: GET "http://localhost:4200/sockjs-node/info?t=1540028075438".
zone.js:2969 XHR 完成加载:OPTIONS "https://firebasestorage.googleapis.com/v0/b/prov-h-fae96.appspot.com/o?name=hospital%2F1540028079723_caps.png"。
只是一堆。没有错误。
有没有其他方法可以获取 downloadUrl 路径?
仅供参考,如果我无法使回调起作用,我就无法订阅 downloadURL。
this.snapshot = this.task.snapshotChanges().pipe(
finalize(()=>{
console.log("percent finalize"); //THIS IS NOT GETTING CALLED;
})
);
【问题讨论】:
-
你需要像
pipe(finalize(...)).subscribe()一样订阅才能触发惰性进程。
标签: javascript angular firebase firebase-storage angularfire2