如何在微服务模块之间使用伪客户端发送多部分文件阵列?

时间:2019-10-03 04:26:10

标签: spring-boot microservices

客户端:

@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);

}

0 个答案:

没有答案