首页 > 解决方案 > ng2-file-upload 设置了错误的 Content-Type

问题描述

我遵循了本教程: https ://valor-software.com/ng2-file-upload/

它适用于 Postman,但当我在我的应用程序中尝试它时却没有。从 api 我返回文件,我从 Postman 看到它们,但在我的应用程序中未定义。

我确实注意到在我的应用程序中我的请求 Content-Type 设置为:

text/plain;charset=UTF-8

我试图设置为:

multipart/form-data

但随后出现边界错误。

有什么建议么?

标签: angularfile-upload

解决方案


我在服务器上改变了这个:

@UseInterceptors(FileInterceptor('files'))

至:

@UseInterceptors(FileInterceptor('file'))

它开始工作,不知道邮递员为什么工作。


推荐阅读