From 78e96892491a603d09ad9b766229cfddb9efdbe4 Mon Sep 17 00:00:00 2001 From: Marcos Lilljedahl Date: Mon, 27 Jul 2020 00:04:31 -0300 Subject: [PATCH] Make path work for both url and data file upload --- handlers/file_upload.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/handlers/file_upload.go b/handlers/file_upload.go index 3578d35..52b5401 100644 --- a/handlers/file_upload.go +++ b/handlers/file_upload.go @@ -25,6 +25,9 @@ func FileUpload(rw http.ResponseWriter, req *http.Request) { } i := core.InstanceGet(s, instanceName) + // Path to upload the file to + path := req.URL.Query().Get("path") + // allow up to 32 MB which is the default // has a url query parameter, ignore body @@ -32,7 +35,7 @@ func FileUpload(rw http.ResponseWriter, req *http.Request) { _, fileName := filepath.Split(url) - err := core.InstanceUploadFromUrl(i, fileName, "", req.URL.Query().Get("url")) + err := core.InstanceUploadFromUrl(i, fileName, path, req.URL.Query().Get("url")) if err != nil { log.Println(err) rw.WriteHeader(http.StatusInternalServerError) @@ -47,7 +50,6 @@ func FileUpload(rw http.ResponseWriter, req *http.Request) { rw.WriteHeader(http.StatusBadRequest) return } - path := req.URL.Query().Get("path") for { p, err := red.NextPart()