Array Multipart[] file upload using Feign client

六月ゝ 毕业季﹏ 提交于 2019-12-12 21:08:03

问题


I am trying to upload Array of Multipart file object using feign client. This is the service am trying to call using Feign client.

public ResponseEntity<Object> manageFileUpload(@RequestParam("files") MultipartFile[] files)

I tried using,Feign client Annotation,

@FeignClient(value = "UPLOADUTILITIES", configuration = Upload.MultipartSupportConfig.class, fallback = UploadFallback.class)

My Method,

@RequestMapping(name = "upload", value = "/object", method = RequestMethod.POST)
@Headers("Content-Type: multipart/form-data")
ResponseEntity<Object> manageFileUpload(@Param("files") MultipartFile[] files);

I was rewarded by the error,

"message": "Type definition error: [simple type, class java.io.FileDescriptor]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile[0]->org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile[\"inputStream\"]->java.io.FileInputStream[\"fd\"])",

Then by referring this link.I tried in my client side, the blow code.

public class MultipartSupportConfig {

    @Autowired
    private ObjectFactory<HttpMessageConverters> messageConverters;

    @Bean
    public Encoder feignFormEncoder() {
        return new SpringFormEncoder(new SpringEncoder(messageConverters));
    }
}

Then by the code example, i changed my MultiPart File object into File Object.Now my request got fired, but i got Not a multipart request.

I tried this https://github.com/pcan/feign-client-test#feign-client-test,

I created a class and used the encoder class, and changed my encoder as FeignSpringFormEncoder,

Still I am getting No serializer found error.

Could anyone share a simple client, server example with Array of Multipart file request, using feign cleint. Thanks!

来源:https://stackoverflow.com/questions/49580267/array-multipart-file-upload-using-feign-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!