0

我必须打电话将文件上传到以下服务:-

@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
public Response uploadFile(
       @RequestParam(value="file", required=true) MultipartFile file, 
       @RequestParam(value="asOfDate" Date asOfDate,
       @RequestHeader(value = "metric") String metric,
       @RequestHeader(value = "user_id") String userId,
       @RequestHeader(value = "user_name") String userName,
       @RequestHeader(value = "user_company_id") String userCompanyId){
 }

截至目前,我正在使用 RestTemplate 调用此服务,但现在我需要将 RestTemplate 调用转换为 Feign Client。

我正在尝试使用 feign 完成多部分文件上传,但我似乎无法在任何地方找到一个很好的例子。

4

1 回答 1

0

以下代码应该可以工作

@FeignClient(
        url = "HOST_URL",
        name = "FileUploadClient")
public interface FileUploadClient {

@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
public Response uploadFile(
       @PathVariable(value="file", required=true) MultipartFile file, 
       @RequestParam(value="asOfDate" Date asOfDate,
       @RequestHeader(value = "metric") String metric,
       @RequestHeader(value = "user_id") String userId,
       @RequestHeader(value = "user_name") String userName,
       @RequestHeader(value = "user_company_id") String userCompanyId){
 }
}
于 2019-01-16T05:58:16.067 回答