我有这段代码可以将文件上传到 aspnet core Api
[HttpPost]
[Produces(typeof(MissionBalanceWithMissionBalanceLinesModel))]
public async Task<IActionResult> UploadBalance(IFormFile upload)
{
return Ok("successfully uploaded");
}
还有角码
const file: File = event.target.files[0];
const upload= new FormData();
fileToUpload.append('upload', file, file.name);
const blob = fileToUpload as any
let options_ : any = {
body: blob,
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
/* "Content-Type": "multipart/form-data", */
"Accept": "text/plain"
})
};
return this.http.request("post", url_, options_)...
错误:System.IO.InvalidDataException:缺少内容类型边界。
评论该/* "Content-Type": "multipart/form-data", */
行会有所帮助,但由于这是 NswagStudio 生成的代码,我想找到另一个解决方法。
或者如何告诉 NswagStudio 不要生成这个 Content-Type 标头?