使用 pIvan/file-upload 和 spring boot 进行 Angular 文件分段上传

问题描述

我有表单控件,其中 value 是 File 对象的数组。 我要上传文件,服务由swagger codegen生成(后端是Java Spring,使用spring boot分段文件上传),看起来像

public uploadContent(name: string,type: string,id: number,body?: Body,observe?: 'body',reportProgress?: boolean): Observable<any>;

我已经提供了名称、类型和 ID,正文是:

export interface Body { 
    file?: Blob;
}

我已经知道 File 是从 Blob 扩展而来的,所以我通过了:

this.service.uploadContent('test1','PICTURE',308,{ file: files[0] })

files[0] 是带有图像的 File 对象,但是当我查看网络后端的请求时,主体是空的,例如:

{"file":{}}

我得到:

message: "Current request is not a multipart request"

解决方法

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

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

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