| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | |
| | | /** |
| | | * 上传图片(上传到项目的webapp/static/img) |
| | | */ |
| | | /* @RequestMapping("/image") |
| | | @RequestMapping("/image") |
| | | public String image(@RequestPart("file") MultipartFile picture) { |
| | | String pictureName = UUID.randomUUID().toString() + ".jpg"; |
| | | try { |
| | |
| | | log.error(e.getMessage(), e); |
| | | throw new GunsException(BizExceptionEnum.UPLOAD_ERROR); |
| | | } |
| | | return pictureName; |
| | | }*/ |
| | | return gunsProperties.getPictureServerAddress()+pictureName; |
| | | } |
| | | |
| | | /** |
| | | * 多图片上传使用 |
| | |
| | | private ITImgMidService itImgMidService; |
| | | |
| | | |
| | | @RequestMapping("/image") |
| | | @ResponseBody |
| | | public ResultUtil image1(@RequestPart("file") MultipartFile file, HttpServletRequest request) { |
| | | try { |
| | | String pictureName = UUID.randomUUID().toString() + "." + ToolUtil.getFileSuffix(file.getOriginalFilename()); |
| | | |
| | | // String pictureName = OssUploadUtil.ossUpload(request, file); |
| | | System.out.println("mediaResp"); |
| | | // MediaResp mediaResp = MediaExample.uploadImage(picture); |
| | | // System.out.println("------"+mediaResp); |
| | | // String pictureName = ObsUploadUtil.obsUpload(super.getHttpServletRequest(), picture); |
| | | return ResultUtil.success(pictureName); |
| | | } catch (Exception e1) { |
| | | e1.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | // @RequestMapping("/image") |
| | | // @ResponseBody |
| | | // public ResultUtil image1(@RequestPart("file") MultipartFile file, HttpServletRequest request) { |
| | | // try { |
| | | // String pictureName = UUID.randomUUID().toString() + "." + ToolUtil.getFileSuffix(file.getOriginalFilename()); |
| | | // |
| | | //// String pictureName = OssUploadUtil.ossUpload(request, file); |
| | | // System.out.println("mediaResp"); |
| | | //// MediaResp mediaResp = MediaExample.uploadImage(picture); |
| | | //// System.out.println("------"+mediaResp); |
| | | //// String pictureName = ObsUploadUtil.obsUpload(super.getHttpServletRequest(), picture); |
| | | // return ResultUtil.success(pictureName); |
| | | // } catch (Exception e1) { |
| | | // e1.printStackTrace(); |
| | | // return null; |
| | | // } |
| | | // } |
| | | |
| | | /** |
| | | * 上传文件 |