We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
我尝试使用这个包进行文件类型判断,但是针对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 附件
The text was updated successfully, but these errors were encountered:
No branches or pull requests
我尝试使用这个包进行文件类型判断,但是针对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
附件
The text was updated successfully, but these errors were encountered: