add error handling on new file
alex wennerberg alex@alexwennerberg.com
Wed, 18 Nov 2020 19:43:52 -0800
1 files changed,
6 insertions(+),
0 deletions(-)
jump to
M
http.go
→
http.go
@@ -142,6 +142,12 @@ renderError(w, InternalServerErrorMsg, 500)
return } newName := filepath.Clean(r.Form.Get("rename")) + err := checkIfValidFile(newName, fileBytes) + if err != nil { + log.Println(err) + renderError(w, err.Error(), 400) + return + } if newName != fileName { newPath := path.Join(c.FilesDirectory, authUser, newName) os.MkdirAll(path.Dir(newPath), os.ModePerm)