客户端:
@FeignClient(名称=“文件服务器”,配置= {FileUploadService.MultipartSupportConfig.class}) @RequestMapping 公用接口FileUploadService {
@RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = MULTIPART_FORM_DATA_VALUE)
public @ResponseBody
List<FileUploadResponseDTO> handleFileUpload(@RequestPart(name = "file") MultipartFile[] file);
@Configuration
public class MultipartSupportConfig {
@Autowired
private ObjectFactory<HttpMessageConverters> messageConverters;
@Bean
@Primary
@Scope("prototype")
public Encoder feignEncoder() {
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
}
@PostMapping(值=“ /上传”,消耗= MULTIPART_FORM_DATA_VALUE) @ApiOperation(UPLOAD_FILE) 公共列表uploadFiles(@RequestPart(name =“ file”)MultipartFile []文件){ System.out.println(“ **** hello ****”);
return fileUploadService.uploadFiles(file);
}