There are http.DetectContentType([]byte)
function in net/http
package. But only limited number of types are supported. How to add support of docx
, doc
, xls
, xlsx
, ppt
, pps
, odt
, ods
, odp
files not by extension, but by the content.
As far as I know, there are some problems, because docx
/xlsx
/pptx
/odp
/odt
files has the same signature as the zip
file (50 4B 03 04).
Disclaimer: I'm the author of mimetype.
For anyone having the same problem 3 years later, nowadays the packages for mime type detection based on the content are the following:
man magic
filetype