mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
filer: set mime type from volume server
This commit is contained in:
parent
1ae83c2938
commit
0375ce2c2e
|
@ -27,6 +27,7 @@ type UploadResult struct {
|
||||||
Error string `json:"error,omitempty"`
|
Error string `json:"error,omitempty"`
|
||||||
ETag string `json:"eTag,omitempty"`
|
ETag string `json:"eTag,omitempty"`
|
||||||
CipherKey []byte `json:"cipherKey,omitempty"`
|
CipherKey []byte `json:"cipherKey,omitempty"`
|
||||||
|
Mime string `json:"mime,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -186,6 +186,7 @@ func (fs *FilerServer) updateFilerStore(ctx context.Context, r *http.Request, w
|
||||||
Replication: replication,
|
Replication: replication,
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
TtlSec: int32(util.ParseInt(r.URL.Query().Get("ttl"), 0)),
|
TtlSec: int32(util.ParseInt(r.URL.Query().Get("ttl"), 0)),
|
||||||
|
Mime: ret.Mime,
|
||||||
},
|
},
|
||||||
Chunks: []*filer_pb.FileChunk{{
|
Chunks: []*filer_pb.FileChunk{{
|
||||||
FileId: fileId,
|
FileId: fileId,
|
||||||
|
@ -194,9 +195,11 @@ func (fs *FilerServer) updateFilerStore(ctx context.Context, r *http.Request, w
|
||||||
ETag: ret.ETag,
|
ETag: ret.ETag,
|
||||||
}},
|
}},
|
||||||
}
|
}
|
||||||
|
if entry.Attr.Mime == "" {
|
||||||
if ext := filenamePath.Ext(path); ext != "" {
|
if ext := filenamePath.Ext(path); ext != "" {
|
||||||
entry.Attr.Mime = mime.TypeByExtension(ext)
|
entry.Attr.Mime = mime.TypeByExtension(ext)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// glog.V(4).Infof("saving %s => %+v", path, entry)
|
// glog.V(4).Infof("saving %s => %+v", path, entry)
|
||||||
if dbErr := fs.filer.CreateEntry(ctx, entry, false); dbErr != nil {
|
if dbErr := fs.filer.CreateEntry(ctx, entry, false); dbErr != nil {
|
||||||
fs.filer.DeleteChunks(entry.Chunks)
|
fs.filer.DeleteChunks(entry.Chunks)
|
||||||
|
|
|
@ -68,6 +68,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
ret.Size = uint32(originalSize)
|
ret.Size = uint32(originalSize)
|
||||||
ret.ETag = needle.Etag()
|
ret.ETag = needle.Etag()
|
||||||
|
ret.Mime = string(needle.Mime)
|
||||||
setEtag(w, ret.ETag)
|
setEtag(w, ret.ETag)
|
||||||
writeJsonQuiet(w, r, httpStatus, ret)
|
writeJsonQuiet(w, r, httpStatus, ret)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue