Skip to content

Commit

Permalink
fix: incorrect content-type of apk files (close #5385)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Nov 6, 2023
1 parent da1c7a4 commit 4355dae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/utils/file.go
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions server/common/proxy.go
Expand Up @@ -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))
}

3 comments on commit 4355dae

@ZAIDU-Miren
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker怎么更新代码~求求求

@anwen-anyi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker怎么更新代码~求求求

xhofe/alist:latest 改成 xhofe/alist:main

@ZAIDU-Miren
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker怎么更新代码~求求求

xhofe/alist:latest 改成 xhofe/alist:main

我试试,感谢你们

Please sign in to comment.