修复文件路径
This commit is contained in:
@ -136,9 +136,6 @@ public class SysWxSaleAccountController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WxFileUploadResult result = WxTokenUtils.uploadImage(oriFilePath, oriFileName, accessToken);
|
WxFileUploadResult result = WxTokenUtils.uploadImage(oriFilePath, oriFileName, accessToken);
|
||||||
if (StringUtils.isEmpty(result.getUrl())) {
|
|
||||||
return AjaxResult.error(result.getMediaId());
|
|
||||||
}
|
|
||||||
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
AjaxResult ajax = AjaxResult.success();
|
||||||
ajax.put("fileName", fileName);
|
ajax.put("fileName", fileName);
|
||||||
|
@ -45,8 +45,7 @@ public class WxTokenUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WxFileUploadResult uploadImage(String filePath, String fileName, String accessToken) {
|
public static WxFileUploadResult uploadImage(String filePath, String fileName, String accessToken) throws Exception {
|
||||||
try {
|
|
||||||
String url = uploadMaterialUrl + "?access_token=" + accessToken + "&type=image";
|
String url = uploadMaterialUrl + "?access_token=" + accessToken + "&type=image";
|
||||||
HttpPostUtil post = new HttpPostUtil(url);
|
HttpPostUtil post = new HttpPostUtil(url);
|
||||||
post.addParameter("media", new File(filePath));
|
post.addParameter("media", new File(filePath));
|
||||||
@ -54,11 +53,6 @@ public class WxTokenUtils {
|
|||||||
JSONObject obj = JSONObject.parseObject(resultStr);
|
JSONObject obj = JSONObject.parseObject(resultStr);
|
||||||
WxFileUploadResult result = JSONObject.toJavaObject(obj, WxFileUploadResult.class);
|
WxFileUploadResult result = JSONObject.toJavaObject(obj, WxFileUploadResult.class);
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
|
||||||
WxFileUploadResult result = new WxFileUploadResult();
|
|
||||||
result.setMediaId(e.getMessage());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user