mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-17 02:33:02 +03:00
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:
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user