diff --git a/static/index.html b/static/index.html index 6c63849..5bfc5f7 100644 --- a/static/index.html +++ b/static/index.html @@ -23,7 +23,7 @@ {{end}}
- + diff --git a/static/upload.html b/static/upload.html index 09821ed..f8c2a43 100644 --- a/static/upload.html +++ b/static/upload.html @@ -10,10 +10,20 @@
MOS3
-
-
+

Upload file

+

Add a file. The file will be uploaded to {{.CurrentPath}}

+
diff --git a/web/ui_controller.go b/web/ui_controller.go index ca32d4b..ba24c41 100644 --- a/web/ui_controller.go +++ b/web/ui_controller.go @@ -25,10 +25,17 @@ func S3Handler(w http.ResponseWriter, r *http.Request) { return } + var currentPath string + if path == "" { + currentPath = "/" + } else { + currentPath = path + } + dataMap := map[string]interface{}{ "S3Objects": s3Objects, "Breadcrumbs": util.GenerateBreadcrumbs(path), - "CurrentPath": path, + "CurrentPath": currentPath, } tmpl, err := template.ParseFiles("static/index.html") diff --git a/web/upload_controller.go b/web/upload_controller.go index f18d4ea..e33a16a 100644 --- a/web/upload_controller.go +++ b/web/upload_controller.go @@ -17,8 +17,12 @@ func UploadIndexHandler(w http.ResponseWriter, r *http.Request) { return } - tmpl.Execute(w, nil) + dataMap := map[string]interface{}{ + "CurrentPath": r.URL.Query().Get("currentPath"), + } + tmpl.Execute(w, dataMap) } + func UploadHandler(w http.ResponseWriter, r *http.Request) { if r.Method != "POST" { http.Error(w, "Invalid request method", http.StatusMethodNotAllowed) @@ -45,5 +49,5 @@ func UploadHandler(w http.ResponseWriter, r *http.Request) { return } - http.Redirect(w, r, "/", http.StatusFound) + http.Redirect(w, r, filepath.Join("/s3", path), http.StatusFound) }