better detect file mime type

This commit is contained in:
Chris Lu committed 2020-04-14 11:32:31 -07:00
1 parent 3f1d79512f
commit 9cacaf5eca
2 files changed
+8 -10

No files matched your search

+6
View File
@@ -77,6 +77,12 @@ func doUploadData(uploadUrl string, filename string, cipher bool, data []byte, i
contentIsGzipped := isInputGzipped
shouldGzipNow := false
if !isInputGzipped {
if mtype == "" {
mtype = http.DetectContentType(data)
if mtype == "application/octet-stream" {
mtype = ""
}
}
if shouldBeZipped, iAmSure := util.IsGzippableFileType(filepath.Base(filename), mtype); iAmSure && shouldBeZipped {
shouldGzipNow = true
} else if !iAmSure && mtype == "" && len(data) > 128 {