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.本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报