apache / apache/incubator-seata
multipart/form-data;boundary= MultipartFile获取不到
- Dominant language
- Java
- Stars
- 26k
- Forks
- 8.8k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 4
Description
- [x] I have searched the [issues](https://github.com/seata/seata/issues) of this repository and believe that this is not a duplicate.
### Ⅰ. Describe what happened
微服务文件上传调用feign上传文件流,开启全局事务时获取不到MultipartFile
提示 Required request part 'file' is not present,不开启时正常获取MultipartFile
### Ⅱ. 解决方案
修改:SeataLoadBalancerFeignClient
```
private Request getModifyRequest(Request request) {
String xid = RootContext.getXID();
if (StringUtils.isEmpty(xid)) {
return request;
} else {
Map> headers = new HashMap(16);
//headers.putAll(request.headers()); Modify
List fescarXid = new ArrayList();
fescarXid.add(xid);
headers.put("TX_XID", fescarXid);
request.headers().putAll(headers);
// Request.create(request.method(), request.url(), headers, request.body(), request.charset()); Modify
return request;
}
}
```
### Ⅲ. How to reproduce it (as minimally and precisely as possible)
1. Controller
@PostMapping(value = "upload", consumes = "multipart/*")
public R upload(@RequestParam("file") MultipartFile file,String businessId){
businessService.upload(file, businessId);
}
2. Service
@GlobalTransactional
public String upload(MultipartFile file, String businessId) {
R result = FeignClient.upload(file, businessId);
}
3. FeignClient:
@RequestMapping(value="/attach/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE, method = RequestMethod.POST)
public R upload(@RequestPart("file") MultipartFile file,@RequestParam("businessId") String businessId);
### Ⅳ. Environment:
- JDK version : 1.8
- seata: spring-cloud-alibaba 2.1.0.RELEASE
Contributor guide
Research direction
Start at SeataLoadBalancerFeignClient.getModifyRequest and reproduce the multipart Feign call described in the issue, comparing behavior with and without @GlobalTransactional. Check that the request still reaches the controller's @RequestPart("file") MultipartFile while the transaction XID is propagated; done means file uploads work in the global-transaction path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100