diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-04-14 11:32:31 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-04-14 11:32:31 -0700 |
| commit | 9cacaf5eca3de4bb8b25d2dc61da4ae4429241cd (patch) | |
| tree | a028527b7d9dfe41af77f929a50b322972299247 /weed/operation | |
| parent | 3f1d79512fbd2ff4c108af5016b38533e4b0300b (diff) | |
| download | seaweedfs-9cacaf5eca3de4bb8b25d2dc61da4ae4429241cd.tar.xz seaweedfs-9cacaf5eca3de4bb8b25d2dc61da4ae4429241cd.zip | |
better detect file mime type
Diffstat (limited to 'weed/operation')
| -rw-r--r-- | weed/operation/upload_content.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go index d4a334f05..5b0441ff9 100644 --- a/weed/operation/upload_content.go +++ b/weed/operation/upload_content.go @@ -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 { |
