修复文件路径

This commit is contained in:
huangdeliang
2021-02-01 13:57:43 +08:00
parent 887bbe6796
commit ff2ec24ee0
2 changed files with 8 additions and 3 deletions

View File

@ -45,10 +45,10 @@ public class WxTokenUtils {
}
}
public static WxFileUploadResult uploadImage(String filePath, String fileName, String accessToken) throws Exception {
public static WxFileUploadResult uploadImage(File file, String fileName, String accessToken) throws Exception {
String url = uploadMaterialUrl + "?access_token=" + accessToken + "&type=image";
HttpPostUtil post = new HttpPostUtil(url);
post.addParameter("media", new File(filePath));
post.addParameter("media", file);
String resultStr = post.send();
JSONObject obj = JSONObject.parseObject(resultStr);
WxFileUploadResult result = JSONObject.toJavaObject(obj, WxFileUploadResult.class);