今天开发项目时,遇到一个需求,需要上传一个excel文件到微服务上,微服务是国外同事写的,
我负责处理gateway和前端部分。在postman上测试接口没有问题了,就准备在代码就实现。
但是遇到了一个问题,无论怎样都调用不成功。此时前端到gateway的调用是成功的,因为我可以把controller
拿到的数据成功写入到本地。问题就出在gateway调用另一个微服务上。
@RequestMapping(value = "/import/excel", method = RequestMethod.POST)
public Object importTableExcel(@RequestParam("file") MultipartFile file, @RequestParam("tableName") String tableName, @RequestParam("importType") String importType) {
return ep2LookUpDBFeignClient.importTableExcel(file, tableName, importType);
}
这个是controller代码,前端用formData封装提交,这里用MultipartFile 接收。到这一步是没有问题的
@RequestMapping(value = "/api/tables/import/excel",
method = RequestMethod.POST,
produces = { MediaType.APPLICATION_JSON_UTF8_VALUE },
cons