diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/controller/SplitFileController.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/controller/SplitFileController.java index 4eb386e25..0ff91553f 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/controller/SplitFileController.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/controller/SplitFileController.java @@ -31,18 +31,18 @@ public class SplitFileController { public void queryPageList(@RequestParam("fileUrl") String fileUrl, HttpServletResponse response, HttpServletRequest request) { //base64解码 - BASE64Decoder base64Decoder = new BASE64Decoder(); - try { - byte[] bytes = base64Decoder.decodeBuffer(fileUrl); - fileUrl = new String(bytes, "utf-8"); - } catch (IOException e) { - throw new JeroBootException("文件不存在"); - } - int splitIndex = fileUrl.lastIndexOf(File.separator); +// BASE64Decoder base64Decoder = new BASE64Decoder(); +// try { +// byte[] bytes = base64Decoder.decodeBuffer(fileUrl); +// fileUrl = new String(bytes, "utf-8"); +// } catch (IOException e) { +// throw new JeroBootException("文件不存在"); +// } + int splitIndex = fileUrl.lastIndexOf("/"); if(splitIndex == -1){ splitIndex = fileUrl.lastIndexOf("/"); } - String fileName = fileUrl.substring(splitIndex); + String fileName = fileUrl.substring(splitIndex + 1); response.setHeader("Content-Disposition", "attachment; filename=\""+fileName+"\""); response.setHeader("Content-Disposition", diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/service/impl/OSSFileServiceImpl.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/service/impl/OSSFileServiceImpl.java index de2744c3e..81742c80b 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/service/impl/OSSFileServiceImpl.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/oss/service/impl/OSSFileServiceImpl.java @@ -284,82 +284,77 @@ public class OSSFileServiceImpl extends ServiceImpl impl } OSSFile oSSFile = new OSSFile(); - try { - String ctxPath = uploadCospath; - String fileName = null; - String fileType = null; + String ctxPath = uploadCospath; + String fileName = null; + String fileType = null; - String orgName = mf.getOriginalFilename();// 获取文件名 - orgName = CommonUtils.getFileName(orgName); - if (orgName.indexOf(".") != -1) { - fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf(".")); - } else { - fileName = orgName + "_" + System.currentTimeMillis(); - } - - String filePath = ctxPath + "/" + fileName; - fileType = orgName.substring(orgName.lastIndexOf(".")); - String fileTypeStr = ".doc,.DOC,.docx,.DOCX,.xls, .XLS,.xlsx,.XLSX,.pdf,.PDF"; - //判断文件类型 - if ("1".equals(state)) { - //固定文件 - if (!fileTypeStr.contains(fileType)) { - if (cut.equals(CutEnum.CN.getValue())) { - throw new JeroBootException("只能够上传pdf,word,excel类型的文件。请重新选择文件!"); - } else { - throw new JeroBootException("Only upload pdf,word,excel type of file Please select the file again!"); - } - } - } else { - if (CommonUtils.limitFileSuffix(orgName, fileSuffixLimits)) { - if (cut.equals(CutEnum.CN.getValue())) { - throw new JeroBootException("不能上传" + StringUtils.join(fileSuffixLimits, ",") + "类型的文件。请重新选择文件!"); - } else { - throw new JeroBootException("Can't upload" + StringUtils.join(fileSuffixLimits, ",") + "type of file Please select the file again!"); - } - } - } - - if (StringUtils.isNotEmpty(fileType)) { - String[] fileTypeArr = {".doc", ".DOC", ".txt", ".TXT", ".docx", ".DOCX", - ".xls", ".XLS", ".xlsx", ".XLSX", ".pdf", ".PDF", ".png", ".PNG", - ".jfif", ".JFIF", ".pjpeg", ".PJPEG", ".jpeg", ".JPEG", ".pjp", ".PJP", - ".jpg", ".JPG", ".swf", ".SWF", ".bmp", ".BMP", ".rar", ".RAR", ".zip", ".ZIP", ".ppt", ".PPT", ".pptx", ".PPTX", ".csv", ".CSV"}; - boolean flag = true; - for (String fileTypeTemp : fileTypeArr) { - if (fileTypeTemp.equalsIgnoreCase(fileType)) { - flag = false; - } - } - if (flag) { - if (cut.equals(CutEnum.CN.getValue())) { - throw new JeroBootException("只能够上传pdf/word/excel/csv/ppt/txt/zip/rar/静态图片类型的文件。请重新选择文件!"); - } else { - throw new JeroBootException("Only upload pdf/word/excel/csv/ppt/txt/zip/rar/静态图片类型的文件。请重新选择文件!"); - } - } - } - - // 将文件上传至腾讯云 cos - CosBootUtil.upload(mf, filePath); - - LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - //存入文件表 - oSSFile.setFileName(orgName); - oSSFile.setId(UuidUtils.getUUID()); - oSSFile.setUrl(filePath); - oSSFile.setCreateBy(loginUser.getUsername()); - oSSFile.setCreateTime(new Date()); - this.save(oSSFile); - // 文件路径做特殊处理 - BASE64Encoder base64Encoder = new BASE64Encoder(); - String encode = base64Encoder.encode(filePath.getBytes(StandardCharsets.UTF_8)); - String imgUrl = splitUrl + "/jero-boot/sys/split/file/getImage?fileUrl=" + encode; - oSSFile.setUrl(imgUrl); - return oSSFile; - } catch (Exception e) { - log.error(e.getMessage(), e); + String orgName = mf.getOriginalFilename();// 获取文件名 + orgName = CommonUtils.getFileName(orgName); + if (orgName.indexOf(".") != -1) { + fileName = orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.lastIndexOf(".")); + } else { + fileName = orgName + "_" + System.currentTimeMillis(); } + + String filePath = ctxPath + "/" + fileName; + fileType = orgName.substring(orgName.lastIndexOf(".")); + String fileTypeStr = ".doc,.DOC,.docx,.DOCX,.xls, .XLS,.xlsx,.XLSX,.pdf,.PDF"; + //判断文件类型 + if ("1".equals(state)) { + //固定文件 + if (!fileTypeStr.contains(fileType)) { + if (cut.equals(CutEnum.CN.getValue())) { + throw new JeroBootException("只能够上传pdf,word,excel类型的文件。请重新选择文件!"); + } else { + throw new JeroBootException("Only upload pdf,word,excel type of file Please select the file again!"); + } + } + } else { + if (CommonUtils.limitFileSuffix(orgName, fileSuffixLimits)) { + if (cut.equals(CutEnum.CN.getValue())) { + throw new JeroBootException("不能上传" + StringUtils.join(fileSuffixLimits, ",") + "类型的文件。请重新选择文件!"); + } else { + throw new JeroBootException("Can't upload" + StringUtils.join(fileSuffixLimits, ",") + "type of file Please select the file again!"); + } + } + } + + if (StringUtils.isNotEmpty(fileType)) { + String[] fileTypeArr = {".doc", ".DOC", ".txt", ".TXT", ".docx", ".DOCX", + ".xls", ".XLS", ".xlsx", ".XLSX", ".pdf", ".PDF", ".png", ".PNG", + ".jfif", ".JFIF", ".pjpeg", ".PJPEG", ".jpeg", ".JPEG", ".pjp", ".PJP", + ".jpg", ".JPG", ".swf", ".SWF", ".bmp", ".BMP", ".rar", ".RAR", ".zip", ".ZIP", ".ppt", ".PPT", ".pptx", ".PPTX", ".csv", ".CSV"}; + boolean flag = true; + for (String fileTypeTemp : fileTypeArr) { + if (fileTypeTemp.equalsIgnoreCase(fileType)) { + flag = false; + } + } + if (flag) { + if (cut.equals(CutEnum.CN.getValue())) { + throw new JeroBootException("只能够上传pdf/word/excel/csv/ppt/txt/zip/rar/静态图片类型的文件。请重新选择文件!"); + } else { + throw new JeroBootException("Only upload pdf/word/excel/csv/ppt/txt/zip/rar/静态图片类型的文件。请重新选择文件!"); + } + } + } + + // 将文件上传至腾讯云 cos + CosBootUtil.upload(mf, filePath); + + LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); + //存入文件表 + oSSFile.setFileName(orgName); + oSSFile.setId(UuidUtils.getUUID()); + oSSFile.setUrl(filePath); + oSSFile.setCreateBy(loginUser.getUsername()); + oSSFile.setCreateTime(new Date()); + this.save(oSSFile); + // 文件路径做特殊处理 +// BASE64Encoder base64Encoder = new BASE64Encoder(); +// String encode = base64Encoder.encode(filePath.getBytes(StandardCharsets.UTF_8)); + String imgUrl = splitUrl + "/jero-boot/sys/split/file/getImage?fileUrl=" + filePath; + oSSFile.setUrl(imgUrl); return oSSFile; } diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java index 2ac7100c7..9a89bcfbd 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSpiltService.java @@ -2570,9 +2570,9 @@ public class FileSpiltService { try { // String fileUrl = splitUrl + "/" + filepathandname; - BASE64Encoder base64Encoder = new BASE64Encoder(); - String encode = base64Encoder.encode(filepathandname.getBytes(StandardCharsets.UTF_8)); - String path = splitUrl+"/jero-boot/sys/split/file/getImage?fileUrl="+encode; +// BASE64Encoder base64Encoder = new BASE64Encoder(); +// String encode = base64Encoder.encode(filepathandname.getBytes(StandardCharsets.UTF_8)); + String path = splitUrl+"/jero-boot/sys/split/file/getImage?fileUrl="+filepathandname; CosBootUtil.uploadByte(bytev, filepathandname); String imgCon = path; String imgConVal = ""; diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java index c78f1a6c5..17389664b 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java @@ -1222,9 +1222,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl"; valEO.setType("IMG"); @@ -1272,9 +1272,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl"; valEO.setType("IMG"); @@ -1319,9 +1319,9 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl"; valEO.setType("IMG"); @@ -3167,19 +3167,18 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl