angular - 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
但随后出现边界错误。
有什么建议么?
解决方案
我在服务器上改变了这个:
@UseInterceptors(FileInterceptor('files'))
至:
@UseInterceptors(FileInterceptor('file'))
它开始工作,不知道邮递员为什么工作。
推荐阅读
- android - 反应本机,屏幕方向不起作用
- node.js - Mongoose session.abortTransaction 不会回滚操作
- tensorflow - Tensorflow Probability (TFP):BNN 图像分类器不使用 OneHotCategorical 层学习
- python - 如何将1000变成1e3?
- c++ - xdevapi for MySQL 使用 c++ 连接器链接器问题
- java - 如何测量 Java 服务中已用内存的大小?
- mysql - 查找从未处理过某个项目的部门
- asp.net-core - 如何解决发布 dot net core Identity Server4 Web 应用程序时出现 HTTP 500 错误
- javascript - P5.js 不会自动清除画布
- python - 全局变量保持不变