Use DetectContentType
to detect the uploaded file content-type
, but the result is always application/octet-stream
.this is just the default return in this function.
So what's the problem?
The standard library's code is only supposed to detect certain types (like HTML that contains one of a few common tags) according to a certain standardized algorithm--more in https://golang.org/src/net/http/sniff.go. You could use github.com/rakyll/magicmime, which uses libmagic and cgo to guess at more file types.