| | |
| | | ZipParameters params = Zip4jHelper.getZipParams(); |
| | | addMetaFiles(zip, params, list); |
| | | |
| | | DownloadEntity downloadEntity = getDownloadEntity(ue, zipFile, pwd); |
| | | String dbPwd = Md5Helper.reverse(Md5Helper.generate(pwd)); |
| | | DownloadEntity downloadEntity = getDownloadEntity(ue, zipFile, dbPwd); |
| | | int rows = downloadMapper.insert(downloadEntity); |
| | | |
| | | return null; |
| | | return rows > 0 ? downloadEntity.getGuid() : null; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private void addMetaFiles(ZipFile zip, ZipParameters params, List<MetaFileEntity> list) { |
| | | String uploadPath = pathHelper.getConfig().getUploadPath(); |
| | | |
| | | int i = 1; |
| | | for (MetaFileEntity entity : list) { |
| | | try { |
| | | File file = new File(uploadPath + File.separator + entity.getPath()); |
| | |
| | | |
| | | FileHeader header = zip.getFileHeader(entity.getGuid()); |
| | | if (null != header) { |
| | | zip.renameFile(header, entity.getName()); |
| | | zip.renameFile(header, i++ + "_" + entity.getName()); |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage(), ex); |
| | |
| | | de.setSizes(FileHelper.sizeToMb(new File(file).length())); |
| | | de.setDepid(ue.getDepid()); |
| | | de.setDcount(0); |
| | | // de.setPwd(null) |
| | | de.setPwd(pwd); |
| | | de.setUrl(FileHelper.getRelativePath(file)); |
| | | de.setDescr("元数据文件"); |
| | | de.setGuid(FileHelper.getFileMd5(file)); |