diff options
| -rw-r--r-- | main.go | 2 | ||||
| -rw-r--r-- | templates/index.html | 16 |
2 files changed, 13 insertions, 5 deletions
@@ -73,7 +73,7 @@ func (handler BoxHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusBadRequest) return } - token := r.Header.Get("X-Upload-Token") + token := r.Header.Get("X-Token") if token != handler.token { log.Println("unauthorized") w.WriteHeader(http.StatusUnauthorized) diff --git a/templates/index.html b/templates/index.html index 9264991..9a03510 100644 --- a/templates/index.html +++ b/templates/index.html @@ -37,16 +37,24 @@ } } xhr.open("POST", "/upload", true); - xhr.setRequestHeader("X-Upload-Token", token) + xhr.setRequestHeader("X-Token", token) xhr.send(f) } </script> </head> <body> - <h1>Box</h1> - <pre>Server for uploading files. Use the form here or send a POST request to /[filename] with the content of the file in the body.</pre> + <pre>Server for uploading files. + +Use the form here or send a POST request to /upload with the content of the file in the body. +If a token has been set on the server, pass the token in the request via a X-Token header. + +The response will contain a X-Resource-ID header containing the ID of the saved file. +This ID can then be used to get the file by sending a GET request to /[resourceID]. + +If enabled on the server, the resource can be deleted by sending a DELETE request to /[resourceID]. +Again if a token has been set on the server, use a X-Token header when sending the request.</pre> {{ if ne . "" }} - <input type="text" id="token"/> + <input type="text" id="token" placeholder="token"/> {{end}} <input type="file" id="file"/><br/><br/> <button type="button" onclick="upload()">Upload</button> |
