List<IFormFile> 文件从 Angular FormData 到 ASP.NET Core 的进度百分比错误百分比值

问题描述

我正在尝试在我的应用程序上添加从 angular 到 ASP.NET Core 的上传进度。但不幸的是,我从 100 获得 this.progressstat 状态,即使上传状态仍然是 IN PROGRESS 多个文件上传。请帮忙。

在我的 Angular 服务中,

    public upload(files): void {
        var formData = new FormData()
        // my files is a collection
        for(let i = 0; i < files.length; i++){
            formData.append("file",files[i],files[i].name)
        }
        
        return this.http.request(new HttpRequest('post','api/upload',formData,{ reportProgress: true }))
    }

这是使用它的组件中的示例方法

   public uploadFile(event){
       this.uploadService.upload(files).subscribe((response:any) => {
           if(response.type === HttpEventType.UploadProgress){
               this.progressstat = Math.Round(100 * response.loaded / response.total)
               this.status = "Uploading"
           }
           if(response.type === HttpEventType.Complete){
               this.progressstat = null // back to zero 
               this.status = "Done"
           }
       })
   }

在我的后端 ASP.NET Core 方面,

[HttpPost]
public async Task<IActionResult> Upload([FromForm(Name = "file")]List<IFormFile> files){
    ...
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...