@ApiOperation(value = "上传图片", notes = "上传图片")
@PostMapping ("upLoadImg")
public OutputObj upLoadImg(
@RequestParam(value = "file") MultipartFile multipartFile
) {
String url = "https://qyapi.weixin.qq.com/cgi-bin/media/uploadimg?access_token="+weChatUtils.getCorpToken();
String body = null;
try {
body = HttpUtil.createPost(url)
.form("fieldNameHere",multipartFile.getBytes(), multipartFile.getOriginalFilename())
.header(Header.CONTENT_TYPE.getValue(), ContentType.MULTIPART.getValue())
.execute().body();
} catch (IOException e) {
e.printStackTrace();
}
//返回参数校验
JSONObject entries = weChatUtils.verifyCorp(body);
return OutputObj.success(entries.getStr("url"), "操作成功");
}
自用,企业微信图片上传
于 2024-05-27 17:45:47 首次发布