我正在使用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();
}