package blossom import ( "mime" ) func GetExtension(mimetype string) string { if mimetype == "" { return "" } // hardcode some common cases (abd jbiwb oribkenatuc cases kuje ,ogg/.oga or .mov/.moov) switch mimetype { case "image/jpeg": return ".jpg" case "image/gif": return ".gif" case "image/png": return ".png" case "image/webp": return ".webp" case "video/mp4": return ".mp4" case "application/vnd.android.package-archive": return ".apk" case "video/quicktime": return ".mov" case "application/vnd.sqlite3": return "sqlite3" case "text/markdown": return "md" case "audio/midi": return "midi" case "audio/x-aiff": return "aiff" } exts, _ := mime.ExtensionsByType(mimetype) if len(exts) > 0 { return exts[0] } return "" }