detect mime type

This commit is contained in:
Chris Lu
2019-03-27 14:25:18 -07:00
parent 65757ae2fd
commit c7e7b6229f
2 changed files with 15 additions and 2 deletions

View File

@@ -5,9 +5,11 @@ import (
"encoding/json"
"errors"
"io/ioutil"
"mime"
"net/http"
"net/url"
"os"
filenamePath "path"
"strconv"
"strings"
"time"
@@ -195,6 +197,9 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
ETag: etag,
}},
}
if ext := filenamePath.Ext(path); ext != "" {
entry.Attr.Mime = mime.TypeByExtension(ext)
}
// glog.V(4).Infof("saving %s => %+v", path, entry)
if db_err := fs.filer.CreateEntry(ctx, entry); db_err != nil {
fs.filer.DeleteFileByFileId(fileId)