fix: Case-insensitive attachment extension matching for item photo inference (#725)

Former-commit-id: 3a6865079e68e9c1ee9beda651cbf123c58fcfc6
This commit is contained in:
LINKIWI 2024-01-27 19:28:58 -08:00 committed by GitHub
parent 7753213657
commit ca55e5ba94

View file

@ -4,6 +4,7 @@ import (
"errors" "errors"
"net/http" "net/http"
"path/filepath" "path/filepath"
"strings"
"github.com/hay-kot/homebox/backend/internal/core/services" "github.com/hay-kot/homebox/backend/internal/core/services"
"github.com/hay-kot/homebox/backend/internal/data/ent/attachment" "github.com/hay-kot/homebox/backend/internal/data/ent/attachment"
@ -70,7 +71,7 @@ func (ctrl *V1Controller) HandleItemAttachmentCreate() errchain.HandlerFunc {
// Attempt to auto-detect the type of the file // Attempt to auto-detect the type of the file
ext := filepath.Ext(attachmentName) ext := filepath.Ext(attachmentName)
switch ext { switch strings.ToLower(ext) {
case ".jpg", ".jpeg", ".png", ".webp", ".gif", ".bmp", ".tiff": case ".jpg", ".jpeg", ".png", ".webp", ".gif", ".bmp", ".tiff":
attachmentType = attachment.TypePhoto.String() attachmentType = attachment.TypePhoto.String()
default: default: