I need to upload a MultipartFile to a third-party service via my own backend service. The parameter in the multipart form is 'nameA' but the third-party service need its param name is 'nameB'.
Normally I can solve it in two ways:
- Change the param name of frontend to 'nameB'
- Change the param name of MultipartFile to 'nameB' in backend service.
But I cannot change the frontend now, so I want to finger out how to modify the param name of MultipartFile in backend service.
The controller of backend service is:
@PostMapping("/url")
public Response method(@RequestParam("nameA") MultipartFile file) {
return Service.method(file);
}
In Feign Client for uploading file to third-party service:
@PostMapping(value = "/url1/url2", consumes = MULTIPART_FORM_DATA_VALUE)
Response method(@RequestParam("nameB") MultipartFile file);
However the use of specify the param with @RequestParam doesn't work.
So does anyone know how to modify the param name of MultipartFile? Thanks a lot!