fix: decouple images from app config service (#965)

Co-authored-by: Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com>
This commit is contained in:
Elias Schneider
2025-09-20 21:42:52 +02:00
committed by GitHub
parent cc34aca2a0
commit a3da943aa6
19 changed files with 426 additions and 314 deletions

View File

@@ -10,6 +10,7 @@ import (
"mime/multipart"
"os"
"path/filepath"
"strings"
"syscall"
"github.com/google/uuid"
@@ -24,6 +25,15 @@ func GetFileExtension(filename string) string {
return filename
}
// SplitFileName splits a full file name into name and extension.
func SplitFileName(fullName string) (name, ext string) {
dot := strings.LastIndex(fullName, ".")
if dot == -1 || dot == 0 {
return fullName, "" // no extension or hidden file like .gitignore
}
return fullName[:dot], fullName[dot+1:]
}
func GetImageMimeType(ext string) string {
switch ext {
case "jpg", "jpeg":