blossom: GetExtension()

This commit is contained in:
fiatjaf
2026-01-12 15:45:53 -03:00
parent 5efcbbfddb
commit 14acd4b740
4 changed files with 39 additions and 35 deletions

31
nipb0/blossom/utils.go Normal file
View File

@@ -0,0 +1,31 @@
package blossom
import "mime"
func GetExtension(mimetype string) string {
if mimetype == "" {
return ""
}
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"
}
exts, _ := mime.ExtensionsByType(mimetype)
if len(exts) > 0 {
return exts[0]
}
return ""
}