Browse Source

Removed detectMimeType

pull/1540/head
Gaspare Iengo 5 years ago
parent
commit
ac4b8800cb
  1. 1
      docker/Dockerfile.go_build
  2. 8
      weed/command/filer_copy.go

1
docker/Dockerfile.go_build

@ -1,6 +1,7 @@
FROM frolvlad/alpine-glibc as builder FROM frolvlad/alpine-glibc as builder
RUN apk add git go g++ RUN apk add git go g++
RUN mkdir -p /go/src/github.com/chrislusf/ RUN mkdir -p /go/src/github.com/chrislusf/
ADD https://api.github.com/repos/Dando-Real-ITA/seaweedfs/git/refs/heads/develop version.json
RUN git clone --depth 1 https://github.com/Dando-Real-ITA/seaweedfs -b develop /go/src/github.com/chrislusf/seaweedfs RUN git clone --depth 1 https://github.com/Dando-Real-ITA/seaweedfs -b develop /go/src/github.com/chrislusf/seaweedfs
RUN cd /go/src/github.com/chrislusf/seaweedfs/weed && go install RUN cd /go/src/github.com/chrislusf/seaweedfs/weed && go install

8
weed/command/filer_copy.go

@ -277,7 +277,8 @@ func (worker *FileCopyWorker) uploadFileAsOne(task FileCopyTask, f *os.File) err
// upload the file content // upload the file content
fileName := filepath.Base(f.Name()) fileName := filepath.Base(f.Name())
mimeType := detectMimeType(f)
// mimeType := detectMimeType(f)
mimeType := "application/octet-stream"
data, err := ioutil.ReadAll(f) data, err := ioutil.ReadAll(f)
if err != nil { if err != nil {
return err return err
@ -364,7 +365,8 @@ func (worker *FileCopyWorker) uploadFileAsOne(task FileCopyTask, f *os.File) err
func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File, chunkCount int, chunkSize int64) error { func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File, chunkCount int, chunkSize int64) error {
fileName := filepath.Base(f.Name()) fileName := filepath.Base(f.Name())
mimeType := detectMimeType(f)
// mimeType := detectMimeType(f)
mimeType := "application/octet-stream"
chunksChan := make(chan *filer_pb.FileChunk, chunkCount) chunksChan := make(chan *filer_pb.FileChunk, chunkCount)
@ -486,7 +488,7 @@ func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File,
func detectMimeType(f *os.File) string { func detectMimeType(f *os.File) string {
head := make([]byte, 512) head := make([]byte, 512)
f.Seek(0, io.SeekStart) f.Seek(0, io.SeekStart)
n, err := f.Read(head)
_, err := f.Read(head)
if err == io.EOF { if err == io.EOF {
return "" return ""
} }

Loading…
Cancel
Save