fix
All checks were successful
Build and Deploy Go App / build (push) Successful in 5m59s
Build and Deploy Go App / deploy (push) Successful in 37s

This commit is contained in:
Iron_Felix 2025-12-06 04:34:18 +03:00
parent 184868b142
commit 5acc53ec9d

View file

@ -85,7 +85,6 @@ func (s *Server) PostMediaUpload(ctx context.Context, request oapi.PostMediaUplo
} }
} }
// Перекодируем в чистый JPEG (без EXIF, сжатие, RGB)
var buf bytes.Buffer var buf bytes.Buffer
err = imaging.Encode(&buf, img, imaging.PNG) err = imaging.Encode(&buf, img, imaging.PNG)
if err != nil { if err != nil {
@ -99,13 +98,14 @@ func (s *Server) PostMediaUpload(ctx context.Context, request oapi.PostMediaUplo
filename = "upload_" + generateRandomHex(8) + ".jpg" filename = "upload_" + generateRandomHex(8) + ".jpg"
} else { } else {
filename = sanitizeFilename(filename) filename = sanitizeFilename(filename)
if !strings.HasSuffix(strings.ToLower(filename), ".jpg") { if !strings.HasSuffix(strings.ToLower(filename), ".png") {
filename += ".jpg" filename += ".png"
} }
} }
// TODO: пойти на хуй ( вызвать файловую помойку) // TODO: пойти на хуй ( вызвать файловую помойку)
err = os.WriteFile(filepath.Join("/uploads", filename), buf.Bytes(), 0644) os.Mkdir("uploads", 0644)
err = os.WriteFile(filepath.Join("./uploads", filename), buf.Bytes(), 0644)
if err != nil { if err != nil {
log.Errorf("PostMedia failed to write: %v", err) log.Errorf("PostMedia failed to write: %v", err)
return oapi.PostMediaUpload500Response{}, nil return oapi.PostMediaUpload500Response{}, nil