liubao68 commented on issue #4628:
URL: 
https://github.com/apache/servicecomb-java-chassis/issues/4628#issuecomment-2520287972

   分析了下, 应该是现在文件上传的参数类型(客户端类型)还不能支持 MultiPartFile. 开发指南有说明只支持下面的类型:
   ```
   java.io.File
   javax.servlet.http.Part
   java.io.InputStream
   org.springframework.core.io.Resource
   ```
   
   可以考虑简单的给你的代码修改下:
   ```
       Map<String,  Object> upLoadMap = new HashMap<>();
       upLoadMap.put("file", file.getInputStream());
       upLoadMap.put("fileType", fileType);
       String url = "servicecomb://provider/provider/saveFile";
       HttpHeaders headers = new HttpHeaders();
       headers.setContentType(MediaType.MULTIPART_FORM_DATA);
       HttpEntity<Map<String, Object>> entity = new HttpEntity<>(upLoadMap, 
headers);
       return restOperation.postForObject(url,entity, String.class);
   ```
   
   
   或者将
   ```
   @RequestMapping(value = "/saveFile",method = RequestMethod.POST,consumes = 
MediaType.MULTIPART_FORM_DATA_VALUE)
       String saveFile(@RequestPart("fileType") int fileType,
                           @RequestPart("file") MultipartFile file)throws 
IOException;
   ```
   改成
   
   ```
   @RequestMapping(value = "/saveFile",method = RequestMethod.POST,consumes = 
MediaType.MULTIPART_FORM_DATA_VALUE)
       String saveFile(@RequestPart("fileType") int fileType,
                           @RequestPart("file") Part file)throws IOException;
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to