我目前有一个解决方案,可以将多个文件上传到Azure Blob存储,但进度条在每个文件后都不会重置(保持在100) .
我知道你可以使用Promise,但我是Angular的新手并且不知道如何最好地接近它?
这是我当前的代码(可行),它将文件存储在一个数组中
上传文件() {
while (this.targetFiles.length > 0)
{
this.targetFile = this.targetFiles.pop();
this.uploadProgress = this.blob
.uploadToBlobStorage(accessToken, this.targetFile);
this.currentPageSub =
this.uploadProgress.subscribe((total: number) => {
this.progress=total;
});
}
}
但我想一次上传一个文件,在上传文件后重置订阅功能中的进度条(this.progress)
有什么建议?
1 回答
您应该在每个周期中重置进度 .