I would like to pass multipart file from one service to another.
Client --> Service1 --> Service2
This shows an error "500 internal server error, Current request is not a multipart request" when I pass the file from Service1 to Service2
Client --> Service2 when I send the file directly its working but not through Service1
I want to know what could be the reason, I guess I am missing some header parts when passing the multipart file as parameter.
Service2
@PostMapping(path="/upload")
public ResponseEntity<Properties> upload(@RequestParam("file") MultipartFile multiPart) {
return saveFile(multiPart);
}
Service2-client
@FeignClient
(name="${feign.upload.serverId}", configuration = UploadServiceClientConfiguration.class, decode404 = true)
public interface UploadServiceClient {
@PostMapping(path="/upload")
ResponseEntity<Properties> upload(@RequestParam("file") MultipartFile multiPart);
class UploadServiceClientConfiguration {
@Value(value="${feign.upload.user}")
String user;
@Value(value="${feign.upload.password}")
String password;
@Bean
public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
return new BasicAuthRequestInterceptor(user, password);
}
}
}
Service1
@Autowired
UploadServiceClient uploadSvcClient;
@PostMapping(path="/upload")
public ResponseEntity<Properties> uploadAttachment(@RequestParam("file") MultipartFile file) {
return uploadSvcClient.upload(file);
}