reactjs - 反应:Axios 发布一个带有 blob 文件的数组,但发生 415 错误
问题描述
我正在尝试将包含多个 blob 文件的数组从 React 上传到 springboot 后端服务器。数组是这样的 [blob, blob, blob, blob, ...]
我应该制作几个网络摄像头捕获图像并一次请求 Axios Post,所以我用 blob 制作了那个数组。但是发生了415错误。
下面是 react.js 代码
const interviewSubmit = () =>{
var formdata = new FormData();
formdata.append("file", captureImgBlob)
axios({
url:baseURL + "test/interview/face",
method:'post',
headers: {
'Content-Type': 'multipart/form-data'
},
body:formdata,
})
.then((res)=>{
console.log(res)
})
.catch((err)=>{
console.log(formdata)
})
}
和springboot代码
@PostMapping(value = "/test/interview/face" , consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<EvalEmotionRes> getInput(@RequestPart List<MultipartFile> image) throws IOException {
return ResponseEntity.ok().body(emotionService.emotionResult(image));
}
这是错误消息 错误消息 如何使此代码正常工作?
解决方案
推荐阅读
- functional-programming - 为什么 Phoenix 中的控制器动作作为原子而不是函数传递?
- javascript - 动态更改指南的 value 和 toValue (AMCharts)
- java - What's causing my SocketException: Connection reset?
- android - 我如何使约束布局以编程方式包装我的文本视图
- javascript - 在 Javascript 中推送数据,作为 Int 而不是字符串
- docker - 本地 GitLab docker 容器中的邮件服务
- python - 如果满足条件,则在 Pyspark 中合并两行
- node.js - 扩展的 CSS on Sass Compile in Node
- spring - 在 Spring 数据查询方法中使用 where 过滤器的不同值的计数
- ruby-on-rails - 如何从单个模型/表中提取分组结果并提供给视图