【发布时间】:2017-04-05 22:53:35
【问题描述】:
我正在使用ng2-file-upload 包访问ASP.NET Core 后端。
https://github.com/valor-software/ng2-file-upload
使用基本示例,尝试测试上传 ~50MB 的大文件。
文件最终会上传,但没有进行任何进度/块操作。基本上坐了一会儿就全部上传了。
我需要更改哪些内容才能获得进度/块上传?
ng2 组件:
import { Component, OnInit } from '@angular/core';
import { FileUploader } from 'ng2-file-upload';
@Component({
selector: 'fileupload',
templateUrl: './fileupload.component.html'
})
export class FileUploadComponent implements OnInit {
public uploader: FileUploader = new FileUploader({ url: '/api/purchaseorder/upload' });
ngOnInit() {
this.uploader.onCompleteItem = (item: any, response: any, status: any, headers: any) => {
console.log("ImageUpload:uploaded:", item, status);
};
}
public hasBaseDropZoneOver: boolean = false;
public hasAnotherDropZoneOver: boolean = false;
public fileOverBase(e: any): void {
this.hasBaseDropZoneOver = e;
}
public fileOverAnother(e: any): void {
this.hasAnotherDropZoneOver = e;
}
}
asp.net mvc 控制器/动作:
public ActionResult Upload(IFormFile file)
{
if (file == null || file.Length == 0)
{
return NoContent();
}
// handle file here
return Ok();
}
【问题讨论】:
-
嗨,你有什么解决办法吗?
标签: file-upload asp.net-core-mvc ng2-file-upload