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/hc/HttpComponentsMinishopMediaUploadRequestCustomizeExecutor.java:42
* @author altusea
*/
@Slf4j
public class HttpComponentsMinishopMediaUploadRequestCustomizeExecutor extends MinishopUploadRequestCustomizeExecutor<CloseableHttpClient, HttpHost> {
public HttpComponentsMinishopMediaUploadRequestCustomizeExecutor(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.EXTENDED)
.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(org.apache.hc.client5.http.entity.mime.HttpMultipartMode.EXTENDED)
.build();View on GitHub (pinned to 1c43293a3c)
Solutions
- 调用上传接口前检查上传文件对象是否为 null,确保传入有效的文件。
- 在上传前验证文件存在且大小大于 0。
When it happens
Trigger: Thrown at weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/hc/HttpComponentsMinishopMediaUploadRequestCustomizeExecutor.java:42 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/f2d6ccaeb2f76031.
Report an issue: GitHub.