|
@ -4,12 +4,9 @@ import ( |
|
|
"context" |
|
|
"context" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"math" |
|
|
"math" |
|
|
"mime" |
|
|
|
|
|
"path" |
|
|
|
|
|
|
|
|
"net/http" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
"github.com/gabriel-vasile/mimetype" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/filer2" |
|
|
"github.com/chrislusf/seaweedfs/weed/filer2" |
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" |
|
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" |
|
@ -130,12 +127,7 @@ func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *f |
|
|
|
|
|
|
|
|
if req.Offset == 0 { |
|
|
if req.Offset == 0 { |
|
|
// detect mime type
|
|
|
// detect mime type
|
|
|
detectedMIME := mimetype.Detect(data) |
|
|
|
|
|
fh.contentType = detectedMIME.String() |
|
|
|
|
|
if ext := path.Ext(fh.f.Name); ext != detectedMIME.Extension() { |
|
|
|
|
|
fh.contentType = mime.TypeByExtension(ext) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fh.contentType = http.DetectContentType(data) |
|
|
fh.dirtyMetadata = true |
|
|
fh.dirtyMetadata = true |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|