| | |
| | | import io.swagger.annotations.Api; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.common.utils.ImageUtils; |
| | | import org.springblade.common.utils.WeiXinSecurityUtil; |
| | | import org.springblade.core.launch.constant.AppConstant; |
| | |
| | | @Api(value = "对象存储端点", tags = "对象存储端点") |
| | | @RequestMapping(AppConstant.APPLICATION_RESOURCE_NAME + "/oss/endpoint") |
| | | public class OssEndpoint { |
| | | private static final Logger logger = LoggerFactory.getLogger(OssEndpoint.class); |
| | | |
| | | /** |
| | | * 对象存储构建类 |
| | |
| | | * @return attachId |
| | | */ |
| | | private Long buildAttachData(Long attachId, String fileName, Long fileSize, BladeFile bladeFile, MultipartFile file) { |
| | | String fileExtension = FileUtil.getFileExtension(fileName); |
| | | AttachData attach = new AttachData(); |
| | | attach.setAttachId(attachId); |
| | | attach.setName(bladeFile.getName()); |
| | | attach.setOriginalName(bladeFile.getOriginalName()); |
| | | attach.setSize(fileSize); |
| | | attach.setExtension(fileExtension); |
| | | attach.setData(ImageUtils.mulToBase64(file)); |
| | | attachDataService.save(attach); |
| | | return attach.getId(); |
| | | try { |
| | | String fileExtension = FileUtil.getFileExtension(fileName); |
| | | AttachData attach = new AttachData(); |
| | | attach.setAttachId(attachId); |
| | | attach.setName(bladeFile.getName()); |
| | | attach.setOriginalName(bladeFile.getOriginalName()); |
| | | attach.setSize(fileSize); |
| | | attach.setExtension(fileExtension); |
| | | attach.setData(ImageUtils.mulToBase64(file)); |
| | | attachDataService.save(attach); |
| | | return attach.getId(); |
| | | } catch (Exception e) { |
| | | logger.error("附件数据表保存失败", e); |
| | | } |
| | | return 0L; |
| | | } |
| | | |
| | | /** |