Giter Site home page Giter Site logo

FileTypeUtil 在分析 DOCX,PPTX,XLSX 文件类型时, 会被 ZIP 逻辑处理掉,不能被DOCX,PPTX,XLSX的match方法处理 about hutool HOT 2 CLOSED

cikecool avatar cikecool commented on June 4, 2024
FileTypeUtil 在分析 DOCX,PPTX,XLSX 文件类型时, 会被 ZIP 逻辑处理掉,不能被DOCX,PPTX,XLSX的match方法处理

from hutool.

Comments (2)

looly avatar looly commented on June 4, 2024

image

这块逻辑是这样的:

先发现是zip,则继续判断是否为office格式:

image

但是也会存在判断不准确的问题,这是文件本身的问题。考虑使用扩展名辅助判断。

from hutool.

CherryRum avatar CherryRum commented on June 4, 2024

还有一个问题,由于office文件的标识很容易被破坏,隐藏的也比较深(没有在前几十字节),所以建议您尝试下
image

 String typeByPath = FileTypeUtil.getType((FileUtil.getInputStream("/Users/lin/code/mine/java/hutool_test/src/main/java/org/example/sql/新建 Microsoft Word 文档.docx")),true);

本地测试应该没有问题,注意不要使用wps修改,这个我也没办法,他会写很多自己的信息到文件信息里面。

from hutool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.