From 45730ba5b4de56fed27f79f8c822bb59d41f7a38 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Fri, 29 Nov 2019 19:18:30 -0700 Subject: upload: early return when no files to upload --- system/admin/upload/upload.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/admin/upload/upload.go b/system/admin/upload/upload.go index a0568e4..fd29796 100644 --- a/system/admin/upload/upload.go +++ b/system/admin/upload/upload.go @@ -31,11 +31,15 @@ func StoreFiles(req *http.Request) (map[string]string, error) { ts = fmt.Sprintf("%d", int64(time.Nanosecond)*time.Now().UnixNano()/int64(time.Millisecond)) // Unix() returns seconds since unix epoch } - req.Form.Set("timestamp", ts) - // To use for FormValue name:urlPath urlPaths := make(map[string]string) + if len(req.MultipartForm.File) == 0 { + return urlPaths, nil + } + + req.Form.Set("timestamp", ts) + // get or create upload directory to save files from request pwd, err := os.Getwd() if err != nil { -- cgit v1.2.3