| | |
| | | package com.ycl.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.io.IORuntimeException; |
| | | import cn.hutool.core.util.CharsetUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.core.util.ZipUtil; |
| | |
| | | } |
| | | |
| | | tempDir = Files.createTempDirectory("temp-dir").toFile(); |
| | | ZipUtil.unzip(tempZip, tempDir, StandardCharsets.ISO_8859_1); |
| | | |
| | | try { |
| | | ZipUtil.unzip(tempZip, tempDir, CharsetUtil.CHARSET_UTF_8); |
| | | }catch (IORuntimeException e){ |
| | | log.error("解压失败,尝试使用GBK编码解压..."); |
| | | ZipUtil.unzip(tempZip, tempDir, CharsetUtil.CHARSET_GBK); |
| | | } |
| | | |
| | | Path path = tempDir.toPath(); |
| | | ProjectImportListener projectImportListener = new ProjectImportListener(); |
| | |
| | | files.forEach(attachmentFile -> { |
| | | try { |
| | | //上传 |
| | | String url = FileUploadUtils.upload(filePath, file); |
| | | String url = FileUploadUtils.uploadIOFile(filePath, attachmentFile); |
| | | //存放的文件名会加上_时间戳的后缀 |
| | | String newName = FileUtils.getName(url); |
| | | attachments.add(new File() |