html - 如何在Angular中按顺序上传文件?
问题描述
我目前有一个将多个文件上传到 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)
有什么建议么?
解决方案
您应该重置每个周期的进度。
while (this.targetFiles.length > 0)
{
this.progress=0;
this.targetFile = this.targetFiles.pop();
this.uploadProgress = this.blob
.uploadToBlobStorage(accessToken, this.targetFile);
this.currentPageSub =
this.uploadProgress.subscribe((total: number) => {
this.progress=total;
});
}
}
推荐阅读
- xml - Blogger 显示“小部件标题无标题”
- python-2.7 - 我没有在 microsoft graph api 一个驱动器端点中获取下载 url
- python - 按键时监视鼠标坐标
- c++ - 可以在while循环中分离声明和条件吗?
- reactjs - 如何使用 Typescript 在 Jest 中模拟 Firebase / Firestrore?
- node.js - 错误:Route.delete() 需要回调函数,但得到了 [object Undefined]
- python - 类型错误:strptime() 参数 1 必须是 str,而不是 TimeStamp - Python
- powerapps - 两个门户用户属性过滤器。可能吗?
- mongodb - 在 Mongo 中更新嵌套数组对象
- r - 如果 R 脚本在 Power BI 中出现错误,有什么方法可以显示错误消息