Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xlsx类型的文件解析为zip格式 #133

Open
zhuqiming opened this issue Jun 7, 2023 · 0 comments
Open

xlsx类型的文件解析为zip格式 #133

zhuqiming opened this issue Jun 7, 2023 · 0 comments

Comments

@zhuqiming
Copy link

我尝试使用这个包进行文件类型判断,但是针对excel格式的文件,会存在有些excel被判断为zip格式导致我上传的时候指定错了文件类型,我跟踪源码发现,最终在doc类型的判断方法中,返回了TYPE_OOXML类型,最终在zip的判断方法中,判断通过,认为我上传的excel是一个zip类型,请问这个要怎么解决呢?是我上传的文件有问题吗?

示例代码如下:
func TestFileType(t *testing.T) {
file, err := os.OpenFile("文件路径", os.O_RDWR, 0)
if err != nil {
t.Errorf("err[%+v]", err)
return
}
buf, err := ioutil.ReadAll(file)
if err != nil {
t.Log(err)
return
}
kind, _ := filetype.Match(buf)
t.Logf("MIME[%+v],Extension[%s]", kind.MIME.Value, kind.Extension)
}
输出结果:
imagesvc_test.go:47: MIME[application/zip],Extension[zip]

上传文件见
联系人跟进状态分布-2023-06-07 15_26_33.xlsx
附件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant