binarywang/WxJava · error · WxErrorException
-99
-99
Error message
上传文件为空
What it means
Error "上传文件为空" thrown in binarywang/WxJava.
Source
Thrown at weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMinishopMediaUploadRequestCustomizeExecutor.java:39
/**
* Created by liming1019 on 2021/8/10.
*/
@Slf4j
public class ApacheMinishopMediaUploadRequestCustomizeExecutor extends MinishopUploadRequestCustomizeExecutor<CloseableHttpClient, HttpHost> {
public ApacheMinishopMediaUploadRequestCustomizeExecutor(RequestHttp<CloseableHttpClient, HttpHost> requestHttp, String respType, String imgUrl) {
super(requestHttp, respType, imgUrl);
}
@Override
public WxMinishopImageUploadCustomizeResult execute(String uri, File file, WxType wxType) throws WxErrorException, IOException {
HttpPost httpPost = new HttpPost(uri);
if (requestHttp.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build();
httpPost.setConfig(config);
}
if (this.uploadType.equals("0")) {
if (file == null) {
throw new WxErrorException("上传文件为空");
}
HttpEntity entity = MultipartEntityBuilder
.create()
.addBinaryBody("media", file)
.addTextBody("resp_type", this.respType)
.addTextBody("upload_type", this.uploadType)
.setMode(HttpMultipartMode.RFC6532)
.build();
httpPost.setEntity(entity);
}
else {
HttpEntity entity = MultipartEntityBuilder
.create()
.addTextBody("resp_type", this.respType)
.addTextBody("upload_type", this.uploadType)
.addTextBody("img_url", this.imgUrl)
.setMode(HttpMultipartMode.RFC6532)
.build();View on GitHub (pinned to 1c43293a3c)
Solutions
- 调用上传接口前检查上传文件对象是否为 null,确保传入有效的文件或输入流。
- 在使用 CommonsMultipartFile / File 前先验证文件存在且大小大于 0。
When it happens
Trigger: Thrown at weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/apache/ApacheMinishopMediaUploadRequestCustomizeExecutor.java:39 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14).
Data as JSON: /api/errors/a86403f51e88f109.
Report an issue: GitHub.