管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-18 1cff0db408a330482391397d00d6d22ce28ade69
src/main/java/com/lf/server/service/data/UploaderService.java
@@ -67,6 +67,7 @@
            String filePath = pathHelper.getTempPath() + File.separator + oldName;
            File newFile = new File(filePath);
            file.transferTo(newFile);
            long sizes = file.getSize();
            // 获取MD5
            String md5 = getFileMd5(filePath);
@@ -76,7 +77,7 @@
                return ctrl.success("文件已存在", md5);
            }
            AttachEntity ae = getAttachEntity(ue, tab, oldName, md5);
            AttachEntity ae = getAttachEntity(ue, tab, oldName, md5, sizes);
            String targetPath = pathHelper.getConfig().getUploadPath() + File.separator + ae.getPath();
            newFile.renameTo(new File(targetPath));
@@ -96,13 +97,14 @@
        return md5;
    }
    protected AttachEntity getAttachEntity(UserEntity ue, String tab, String oldName, String md5) {
    protected AttachEntity getAttachEntity(UserEntity ue, String tab, String oldName, String md5, long sizes) {
        AttachEntity entity = new AttachEntity();
        entity.setName(oldName);
        entity.setTab(tab);
        entity.setGuid(md5);
        String subPath = PathHelper.getUploadPath() + File.separator + md5;
        entity.setPath(subPath);
        entity.setSizes(sizes);
        if (ue != null) {
            entity.setCreateUser(ue.getId());
        }
@@ -221,6 +223,7 @@
            fi.setSize(file.getSize());
            fi.setPath(path + File.separator + fi.getFileName());
            file.transferTo(new File(fi.getPath()));
            fi.setMd5(getFileMd5(fi.getPath()));
            list.add(fi);
        }