定时器,欢迎语

dev
zhenghuang 5 years ago
parent 29c506e38a
commit a1b7c071a1

@ -32,8 +32,7 @@ public class FileController extends BaseController {
@ApiOperation(value = "上传文件")
@PostMapping(value = "/upload")
public Map<String, Object> upload(@RequestParam(value = "file", required = false) MultipartFile file) throws WxErrorException {
WxCpServiceOkHttpImpl serviceOkHttp = WxCpConfiguration.getCpService(WxCpConfiguration.APPLICATIONID);
public Map<String, Object> upload(@RequestParam(value = "file", required = false) MultipartFile file, String needMediaId) throws WxErrorException {
if (file == null) return fail();
String fileName = file.getOriginalFilename();
if (fileName == null) return fail();
@ -51,12 +50,15 @@ public class FileController extends BaseController {
log.error("上传出错", e);
return fail();
}
WxMediaUploadResult result = serviceOkHttp.getMediaService().upload("image", new File(uploadPath + fileName));
log.info("上传成功: {}", result);
Map<String, Object> ret = new HashMap<>();
ret.put("mediaId", result.getMediaId());
if(needMediaId != null) {
WxCpServiceOkHttpImpl serviceOkHttp = WxCpConfiguration.getCpService(WxCpConfiguration.APPLICATIONID);
WxMediaUploadResult result = serviceOkHttp.getMediaService().upload("image", new File(uploadPath + fileName));
log.info("上传成功: {}", result);
ret.put("mediaId", result.getMediaId());
}
ret.put("localPath", "/upload/" + fileName);
return data("/upload/" + fileName);
return data(ret);
}
private String renameToUUID(String filename) {

Loading…
Cancel
Save