From 17c6a4c9a41500f862f4094699304b6bfad459fa Mon Sep 17 00:00:00 2001 From: Gaspare Iengo Date: Thu, 15 Oct 2020 20:36:26 +0000 Subject: [PATCH] Removing DetectContentType --- .gitignore | 2 ++ test/s3/multipart/aws_upload.go | 3 ++- weed/command/filer_copy.go | 3 ++- weed/filesys/filehandle.go | 3 ++- weed/operation/upload_content.go | 3 ++- weed/server/filer_server_handlers_write_cipher.go | 3 ++- weed/storage/needle/needle_parse_upload.go | 3 ++- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 671b01051..5f270177d 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,5 @@ other/java/hdfs/dependency-reduced-pom.xml # binary file weed/weed + +.vscode/ diff --git a/test/s3/multipart/aws_upload.go b/test/s3/multipart/aws_upload.go index 8c15cf6ed..6dd321daa 100644 --- a/test/s3/multipart/aws_upload.go +++ b/test/s3/multipart/aws_upload.go @@ -49,7 +49,8 @@ func main() { fileInfo, _ := file.Stat() size := fileInfo.Size() buffer := make([]byte, size) - fileType := http.DetectContentType(buffer) + // fileType := http.DetectContentType(buffer) + fileType := "application/octet-stream" file.Read(buffer) path := "/media/" + file.Name() diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.go index 88148acc5..9280c85aa 100644 --- a/weed/command/filer_copy.go +++ b/weed/command/filer_copy.go @@ -496,7 +496,8 @@ func detectMimeType(f *os.File) string { return "" } f.Seek(0, io.SeekStart) - mimeType := http.DetectContentType(head[:n]) + // mimeType := http.DetectContentType(head[:n]) + mimeType := "application/octet-stream" if mimeType == "application/octet-stream" { return "" } diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index 687588788..c84c88e02 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -154,7 +154,8 @@ func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *f if req.Offset == 0 { // detect mime type - fh.contentType = http.DetectContentType(data) + // fh.contentType = http.DetectContentType(data) + fh.contentType = "application/octet-stream" fh.f.dirtyMetadata = true } diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go index e9002d09d..f783da440 100644 --- a/weed/operation/upload_content.go +++ b/weed/operation/upload_content.go @@ -102,7 +102,8 @@ func doUploadData(uploadUrl string, filename string, cipher bool, data []byte, i shouldGzipNow := false if !isInputCompressed { if mtype == "" { - mtype = http.DetectContentType(data) + // mtype = http.DetectContentType(data) + mtype = "application/octet-stream" // println("detect1 mimetype to", mtype) if mtype == "application/octet-stream" { mtype = "" diff --git a/weed/server/filer_server_handlers_write_cipher.go b/weed/server/filer_server_handlers_write_cipher.go index 60082a8d4..175a880bf 100644 --- a/weed/server/filer_server_handlers_write_cipher.go +++ b/weed/server/filer_server_handlers_write_cipher.go @@ -37,7 +37,8 @@ func (fs *FilerServer) encrypt(ctx context.Context, w http.ResponseWriter, r *ht uncompressedData = pu.UncompressedData } if pu.MimeType == "" { - pu.MimeType = http.DetectContentType(uncompressedData) + // pu.MimeType = http.DetectContentType(uncompressedData) + pu.MimeType = "application/octet-stream" // println("detect2 mimetype to", pu.MimeType) } diff --git a/weed/storage/needle/needle_parse_upload.go b/weed/storage/needle/needle_parse_upload.go index 4d244046e..da4dd0ee9 100644 --- a/weed/storage/needle/needle_parse_upload.go +++ b/weed/storage/needle/needle_parse_upload.go @@ -66,7 +66,8 @@ func ParseUpload(r *http.Request, sizeLimit int64) (pu *ParsedUpload, e error) { ext := filepath.Base(pu.FileName) mimeType := pu.MimeType if mimeType == "" { - mimeType = http.DetectContentType(pu.Data) + // mimeType = http.DetectContentType(pu.Data) + mimeType = "application/octet-stream" } // println("detected mimetype to", pu.MimeType) if mimeType == "application/octet-stream" {