Skip to content

Commit daab224

Browse files
committed
refactor(api): remove unused buffer and content type detection
The buffer creation and content type detection were unused in the image upload logic. Removing these simplifies the code without affecting functionality.
1 parent e6c9b74 commit daab224

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

handlers/api.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"path"
1313
"path/filepath"
1414
"strconv"
15-
"strings"
1615

1716
"ImageServer/config"
1817
"ImageServer/models"
@@ -146,8 +145,6 @@ func (h *APIHandler) UploadImage(c *gin.Context) {
146145
return
147146
}
148147

149-
buffer := bytes.Clone(fileBytes[0:512])
150-
151148
if !models.ConverableTypes.Has(format) {
152149
filePath := filepath.Join(folderPath, id + "." + format)
153150
outputFile, error := os.Create(filePath)
@@ -176,9 +173,6 @@ func (h *APIHandler) UploadImage(c *gin.Context) {
176173
return
177174
}
178175

179-
contentType := http.DetectContentType(buffer)
180-
format = strings.Split(contentType, "/")[1]
181-
182176
if format != "" && !models.SupportedTypes.Has(format) {
183177
c.JSON(http.StatusBadRequest, gin.H{"error": "Unsupported format: " + format})
184178
return

0 commit comments

Comments
 (0)