From d3a613c3351c2906faf9c323135d420a956287be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Thu, 4 Jun 2026 16:10:59 +0000 Subject: [PATCH] fix(dput): replace manual read loop with io.Copy --- api/files.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/api/files.go b/api/files.go index 32e9c491..da2d5c56 100644 --- a/api/files.go +++ b/api/files.go @@ -231,20 +231,9 @@ func apiFilesUploadOne(c *gin.Context) { } defer dst.Close() - buf := make([]byte, 1024) - for { - n, err := c.Request.Body.Read(buf) - if err != nil && err != io.EOF { - AbortWithJSONError(c, 400, err) - return - } - if n == 0 { - break - } - if _, err := dst.Write(buf[:n]); err != nil { - AbortWithJSONError(c, 500, err) - return - } + if _, err = io.Copy(dst, c.Request.Body); err != nil { + AbortWithJSONError(c, 500, err) + return } stored = append(stored, filepath.Join(c.Params.ByName("dir"), c.Params.ByName("file")))