Make path work for both url and data file upload

This commit is contained in:
Marcos Lilljedahl
2020-07-27 00:04:31 -03:00
parent 1aff5d7d5a
commit 78e9689249

View File

@@ -25,6 +25,9 @@ func FileUpload(rw http.ResponseWriter, req *http.Request) {
} }
i := core.InstanceGet(s, instanceName) 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 // allow up to 32 MB which is the default
// has a url query parameter, ignore body // has a url query parameter, ignore body
@@ -32,7 +35,7 @@ func FileUpload(rw http.ResponseWriter, req *http.Request) {
_, fileName := filepath.Split(url) _, 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 { if err != nil {
log.Println(err) log.Println(err)
rw.WriteHeader(http.StatusInternalServerError) rw.WriteHeader(http.StatusInternalServerError)
@@ -47,7 +50,6 @@ func FileUpload(rw http.ResponseWriter, req *http.Request) {
rw.WriteHeader(http.StatusBadRequest) rw.WriteHeader(http.StatusBadRequest)
return return
} }
path := req.URL.Query().Get("path")
for { for {
p, err := red.NextPart() p, err := red.NextPart()