diff --git a/pkg/utils/file.go b/pkg/utils/file.go index 31803a95..7ae07158 100644 --- a/pkg/utils/file.go +++ b/pkg/utils/file.go @@ -163,8 +163,15 @@ func GetObjType(filename string, isDir bool) int { return GetFileType(filename) } +var extraMimeTypes = map[string]string{ + ".apk": "application/vnd.android.package-archive", +} + func GetMimeType(name string) string { ext := path.Ext(name) + if m, ok := extraMimeTypes[ext]; ok { + return m + } m := mime.TypeByExtension(ext) if m != "" { return m diff --git a/server/common/proxy.go b/server/common/proxy.go index 370e46eb..8156dc88 100644 --- a/server/common/proxy.go +++ b/server/common/proxy.go @@ -76,4 +76,5 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model. func attachFileName(w http.ResponseWriter, file model.Obj) { fileName := file.GetName() w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"; filename*=UTF-8''%s`, fileName, url.PathEscape(fileName))) + w.Header().Set("Content-Type", utils.GetMimeType(fileName)) }