handle files declared as .apk as .apk.

fixes https://github.com/fiatjaf/khatru/issues/50
This commit is contained in:
fiatjaf
2025-06-03 18:29:34 -03:00
parent 1a5b498fb8
commit c5076b297d
2 changed files with 7 additions and 1 deletions

View File

@@ -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) {

View File

@@ -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)