| | |
| | | |
| | | import com.yami.trading.bean.model.FileUploadParamsModel; |
| | | import com.yami.trading.bean.vo.FileInfoVo; |
| | | import com.yami.trading.common.constants.Constants; |
| | | import com.yami.trading.common.domain.Result; |
| | | import com.yami.trading.common.exception.YamiShopBindException; |
| | | import com.yami.trading.service.AwsS3OSSFileService; |
| | |
| | | public Result uploadFile(FileUploadParamsModel model) { |
| | | try { |
| | | if (model.getFile().getSize() / 1000L > 4500) { |
| | | throw new YamiShopBindException("图片大小不能超过4M"); |
| | | throw new YamiShopBindException("Image size cannot exceed 4MB"); |
| | | } |
| | | String path= awsS3OSSFileService.uploadFile(model.getModuleName(), model.getFile()); |
| | | FileInfoVo fileInfoVo=new FileInfoVo(); |
| | | fileInfoVo.setHttpUrl(awsS3OSSFileService.getUrl(path)); |
| | | fileInfoVo.setHttpUrl(Constants.IMAGES_HTTP+path); |
| | | fileInfoVo.setPath(path); |
| | | return Result.succeed(fileInfoVo); |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new YamiShopBindException("文件上传失败"); |
| | | throw new YamiShopBindException("File upload failed"); |
| | | } |
| | | } |
| | | } |