OpenFeign / feign

Feign makes writing java http clients easier
Apache License 2.0
9.49k stars 1.93k forks source link

post request upload file in azure,but appear 411 #2493

Open YLIU356Volvocars opened 3 months ago

YLIU356Volvocars commented 3 months ago

I have a request from the client to the service,this is post request upload file in azure ,but occurred 411,the following message appears:

feign.FeignException$FeignClientException: status 411 reading FileServiceClient#handleFileUpload(MultipartFile)
    at feign.FeignException.clientErrorStatus(FeignException.java:181)
    at feign.FeignException.errorStatus(FeignException.java:141)
    at feign.FeignException.errorStatus(FeignException.java:133)
    at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92)
    at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:151)
    at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:80)
    at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
    at com.sun.proxy.$Proxy209.handleFileUpload(Unknown Source)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:769)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:366)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:99)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747)
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

client:
      @PostMapping(value = "/azure/blob/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
      RestResultResponse<FileUploadVO> handleFileUpload(@RequestParam("multipartFile") MultipartFile multipartFile);

service:
     @PostMapping(value = "/uploadFile")
    public ResponseDTO<FileUploadVO> uploadFileFegin(@RequestParam("multipartFile") MultipartFile multipartFile) {
        return  ResponseUtils.success(azureBlobUtil.upload(multipartFile));
    }

Can help me give me some suggest or idea improve it?

kdavisk6 commented 1 month ago

HTTP error code 411 indicates that a file length is required and either not present or incorrect. https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/411

I recommend looking into that status code first.