From 0af48813e74af53cc0b9c93400a78c19e7aacb2f Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Thu, 23 Jan 2025 14:50:03 +0100 Subject: X-Upload-Token -> X-Token and flesh out index.html --- main.go | 2 +- templates/index.html | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index aeb0100..f79a111 100644 --- a/main.go +++ b/main.go @@ -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) } -

Box

-
Server for uploading files. Use the form here or send a POST request to /[filename] with the content of the file in the body.
+
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.
{{ if ne . "" }} - + {{end}}

-- cgit v1.2.3