mirror of
https://github.com/aljazceru/khatru.git
synced 2026-02-19 11:44:24 +01:00
handle files declared as .apk as .apk.
fixes https://github.com/fiatjaf/khatru/issues/50
This commit is contained in:
@@ -86,6 +86,11 @@ func (bs BlossomServer) handleUpload(w http.ResponseWriter, r *http.Request) {
|
||||
ext = getExtension(mimetype)
|
||||
}
|
||||
|
||||
// special case of android apk -- if we see a .zip but they say it's .apk we trust them
|
||||
if ext == ".zip" && getExtension(r.Header.Get("Content-Type")) == ".apk" {
|
||||
ext = ".apk"
|
||||
}
|
||||
|
||||
// run the reject hooks
|
||||
for _, ru := range bs.RejectUpload {
|
||||
reject, reason, code := ru(r.Context(), auth, size, ext)
|
||||
@@ -231,7 +236,6 @@ func (bs BlossomServer) handleHasBlob(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Length", strconv.Itoa(bd.Size))
|
||||
w.Header().Set("Accept-Ranges", "bytes")
|
||||
w.Header().Set("Content-Type", bd.Type)
|
||||
|
||||
}
|
||||
|
||||
func (bs BlossomServer) handleList(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -26,6 +26,8 @@ func getExtension(mimetype string) string {
|
||||
return ".webp"
|
||||
case "video/mp4":
|
||||
return ".mp4"
|
||||
case "application/vnd.android.package-archive":
|
||||
return ".apk"
|
||||
}
|
||||
|
||||
exts, _ := mime.ExtensionsByType(mimetype)
|
||||
|
||||
Reference in New Issue
Block a user