fix
This commit is contained in:
parent
184868b142
commit
5acc53ec9d
1 changed files with 4 additions and 4 deletions
|
|
@ -85,7 +85,6 @@ func (s *Server) PostMediaUpload(ctx context.Context, request oapi.PostMediaUplo
|
|||
}
|
||||
}
|
||||
|
||||
// Перекодируем в чистый JPEG (без EXIF, сжатие, RGB)
|
||||
var buf bytes.Buffer
|
||||
err = imaging.Encode(&buf, img, imaging.PNG)
|
||||
if err != nil {
|
||||
|
|
@ -99,13 +98,14 @@ func (s *Server) PostMediaUpload(ctx context.Context, request oapi.PostMediaUplo
|
|||
filename = "upload_" + generateRandomHex(8) + ".jpg"
|
||||
} else {
|
||||
filename = sanitizeFilename(filename)
|
||||
if !strings.HasSuffix(strings.ToLower(filename), ".jpg") {
|
||||
filename += ".jpg"
|
||||
if !strings.HasSuffix(strings.ToLower(filename), ".png") {
|
||||
filename += ".png"
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
log.Errorf("PostMedia failed to write: %v", err)
|
||||
return oapi.PostMediaUpload500Response{}, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue