jeecgboot/JeecgBoot · error · JeecgBootException

请上传zip压缩包

Error message

请上传zip压缩包

What it means

Thrown by AiragKnowledgeDocServiceImpl.importDocumentFromZip() when the uploaded file's extension is not 'zip' (case-insensitive). The method extracts the extension via FilenameUtils.getExtension() and rejects anything that is null or not equal to 'zip'. This is a file-type guard before the upload and extraction pipeline.

Source

Thrown at jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/service/impl/AiragKnowledgeDocServiceImpl.java:308

    @Transactional(rollbackFor = {java.lang.Exception.class})
    @Override
    public Result<?> importDocumentFromZip(String knowId, MultipartFile zipFile) {
        AssertUtils.assertNotEmpty("请先选择知识库", knowId);
        AssertUtils.assertNotEmpty("请上传文件", zipFile);
        long startTime = System.currentTimeMillis();
        log.info("开始上传知识库文档(zip), 知识库id: {}, 文件名: {}", knowId, zipFile.getOriginalFilename());

        try {
            String bizPath = knowId + File.separator + UUIDGenerator.generate();
            String workDir = uploadpath + File.separator + bizPath + File.separator;
            String sourcesPath = workDir + "files";

            SsrfFileTypeFilter.checkUploadFileType(zipFile);
            // 通过filePath 检查文件是不是压缩包(zip)
            String zipFileName = FilenameUtils.getBaseName(zipFile.getOriginalFilename());
            String fileExt = FilenameUtils.getExtension(zipFile.getOriginalFilename());
            if (null == fileExt || !fileExt.equalsIgnoreCase("zip")) {
                throw new JeecgBootException("请上传zip压缩包");
            }
            String uploadedZipPath = CommonUtils.uploadLocal(zipFile, bizPath, uploadpath);

            //update-begin---wangshuai---date:20260414  for:【QQYUN-14932】创建知识库时,可以创建一个分段策略,知识库里面的文档默认使用知识库的分段策略------------
            // 判断知识库是否配置了默认分段策略
            boolean knowledgeHasDefaultSegment = false;
            AiragKnowledge knowledge = airagKnowledgeMapper.selectById(knowId);
            if (knowledge != null && oConvertUtils.isNotEmpty(knowledge.getMetadata())) {
                try {
                    JSONObject kmeta = JSONObject.parseObject(knowledge.getMetadata());
                    knowledgeHasDefaultSegment = Boolean.TRUE.equals(kmeta.getBoolean(LLMConsts.ENABLE_SEGMENT));
                } catch (Exception ignore) {}
            }
            final boolean useKnowledgeDefault = knowledgeHasDefaultSegment;
            //update-end---author:wangshuai ---date:20260414  for:【QQYUN-14932】创建知识库时,可以创建一个分段策略,知识库里面的文档默认使用知识库的分段策略------------
            
            // 解压缩文件
            List<AiragKnowledgeDoc> docList = new ArrayList<>();

View on GitHub (pinned to 96fb33f5ec)

Solutions

  1. Re-package the files as a .zip archive using the OS's built-in compression or a tool like 7-Zip.
  2. Verify the uploaded file actually has a .zip extension and is a valid zip archive.
  3. If individual files need to be uploaded (not in a zip), use the single-file upload endpoint instead.
Defensive patterns

Strategy: validation

Validate before calling

String fileExt = FilenameUtils.getExtension(zipFile.getOriginalFilename());
if (fileExt == null || !fileExt.equalsIgnoreCase("zip")) {
    throw new JeecgBootException("请上传zip格式的压缩包");
}

Type guard

private static boolean isZipFile(MultipartFile file) {
    if (file == null || file.getOriginalFilename() == null) return false;
    String ext = FilenameUtils.getExtension(file.getOriginalFilename());
    return "zip".equalsIgnoreCase(ext);
}

Prevention

When it happens

Trigger: Uploading a file with extension .rar, .7z, .tar, .gz, .tar.gz, or a file with no extension to the zip-import endpoint. Also triggered if the original filename has no dot (resulting in null extension).

Common situations: User selects a .rar or .7z file instead of .zip; the file was renamed but the content does not match; the browser or OS stripped the extension; user uploads a regular document file (e.g. .pdf) to the zip-import endpoint by mistake.

Related errors


AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14). Data as JSON: /api/errors/0d69d57f7996746b. Report an issue: GitHub.