Browse Source

Removing DetectContentType

pull/1540/head
Gaspare Iengo 5 years ago
parent
commit
17c6a4c9a4
  1. 2
      .gitignore
  2. 3
      test/s3/multipart/aws_upload.go
  3. 3
      weed/command/filer_copy.go
  4. 3
      weed/filesys/filehandle.go
  5. 3
      weed/operation/upload_content.go
  6. 3
      weed/server/filer_server_handlers_write_cipher.go
  7. 3
      weed/storage/needle/needle_parse_upload.go

2
.gitignore

@ -83,3 +83,5 @@ other/java/hdfs/dependency-reduced-pom.xml
# binary file
weed/weed
.vscode/

3
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()

3
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 ""
}

3
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
}

3
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 = ""

3
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)
}

3
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" {

Loading…
Cancel
Save