dongronge3732 2015-06-01 19:12
浏览 15
已采纳

推荐的方法来检查文件是否已压缩/压缩

I am trying to check if an uploaded file ( no file extension) is compressed/ zipped. I searched through the fileinfo, fileheader etc but haven't found a way to do this. May be the magic number? Thanks

  • 写回答

1条回答 默认 最新

  • dongren9739 2015-06-01 19:20
    关注

    A quick-and-easy built-in way is with http.DetectContentType(). It does much more than just gzip/zip, but it's very fast because it doesn't check for too many things. If you want to check for a smaller set, and skip testing a string, check the source code in src/net/http/sniff.go and pull out the tests you want.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?