| | |
| | | import com.stylefeng.guns.core.base.controller.BaseController; |
| | | import com.stylefeng.guns.core.common.exception.BizExceptionEnum; |
| | | import com.stylefeng.guns.core.exception.GunsException; |
| | | import com.stylefeng.guns.core.util.ObsUploadUtil; |
| | | import com.stylefeng.guns.modular.system.util.OssUploadUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | try { |
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| | | MultipartFile file = (MultipartFile) picture; |
| | | |
| | | String name = file.getOriginalFilename(); |
| | | String s = name.substring(name.lastIndexOf(".") + 1).toLowerCase(); |
| | | if(!s.equals("jpg") && !s.equals("png") && !s.equals("jpeg")){ |
| | | return null; |
| | | } |
| | | long size = file.getSize(); |
| | | if(size > 524288000L){//500M限制 |
| | | return "请上传500M以内的文件"; |
| | | } |
| | | String pictureName = OssUploadUtil.ossUpload(request, file); |
| | | // String pictureName = ObsUploadUtil.obsUpload(super.getHttpServletRequest(), picture); |
| | | return pictureName; |
| | |
| | | */ |
| | | @RequestMapping("/file") |
| | | public String file(@RequestPart("file") MultipartFile picture) { |
| | | long size = picture.getSize(); |
| | | if(size > 524288000L){//500M限制 |
| | | return "请上传500M以内的文件"; |
| | | } |
| | | //获取文件名后缀 |
| | | String suffix = picture.getOriginalFilename().substring(picture.getOriginalFilename().lastIndexOf(".")); |
| | | String pictureName = UUID.randomUUID().toString() + suffix; |
| | |
| | | */ |
| | | @RequestMapping("/imageUp") |
| | | public String imageUp(@RequestPart("upfile") MultipartFile picture, HttpServletRequest request) { |
| | | long size = picture.getSize(); |
| | | if(size > 524288000L){//500M限制 |
| | | return "请上传500M以内的文件"; |
| | | } |
| | | String callback = request.getParameter("callback"); |
| | | String pictureName = UUID.randomUUID().toString() + ".jpg"; |
| | | try { |
| | |
| | | // 文件全路径 |
| | | //pictureName = gunsProperties.getPictureServerAddress() + pictureName; |
| | | // pictureName = ObsUploadUtil.obsUpload(super.getHttpServletRequest(), picture); |
| | | |
| | | String name = picture.getOriginalFilename(); |
| | | String s = name.substring(name.lastIndexOf(".") + 1).toLowerCase(); |
| | | if(!s.equals("jpg") && !s.equals("png") && !s.equals("jpeg")){ |
| | | return null; |
| | | } |
| | | |
| | | pictureName = OssUploadUtil.ossUpload(super.getHttpServletRequest(), picture); |
| | | |
| | | String result = "{'original': '" + picture.getOriginalFilename() + "', 'state': 'SUCCESS', 'url': '" + pictureName + "'}"; |