diff --git a/internal/controllers/taskcontroller/upload.go b/internal/controllers/taskcontroller/upload.go index 00fadd0..b87c061 100644 --- a/internal/controllers/taskcontroller/upload.go +++ b/internal/controllers/taskcontroller/upload.go @@ -46,7 +46,7 @@ func (c *TaskController) Upload(w http.ResponseWriter, r *http.Request) { return } - err := r.ParseMultipartForm(10240 << 20) + err := r.ParseMultipartForm(10 << 20) if err != nil { render.Render(w, r, &commonErrors.ErrResponse{ HTTPStatusCode: http.StatusBadRequest, @@ -57,7 +57,7 @@ func (c *TaskController) Upload(w http.ResponseWriter, r *http.Request) { files := r.MultipartForm.File["files"] for _, fileHeader := range files { - if fileHeader.Size > (1024 << 20) { + if fileHeader.Size > (4096 << 20) { render.Render(w, r, &commonErrors.ErrResponse{ HTTPStatusCode: http.StatusBadRequest, StatusText: "File too large", diff --git a/internal/services/taskservice/upload.go b/internal/services/taskservice/upload.go index 8bd54dd..d0ea852 100644 --- a/internal/services/taskservice/upload.go +++ b/internal/services/taskservice/upload.go @@ -86,7 +86,6 @@ func (s *Service) Upload(input *TaskUploadInput) error { if err != nil { return fmt.Errorf("can't open fileHeader %w", err) } - defer file.Close() if !strings.HasSuffix(fileHeader.Filename, ".rpm") { return fmt.Errorf("invalid file type: only .rpm files are allowed") @@ -107,12 +106,13 @@ func (s *Service) Upload(input *TaskUploadInput) error { if err != nil { return err } - defer outFile.Close() _, err = io.Copy(outFile, file) if err != nil { return err } + outFile.Close() + file.Close() pkg, err := rpm.Open(filePath) if err != nil {