From 0f0753ad601474682192e3727455a9371588a940 Mon Sep 17 00:00:00 2001 From: ZizzyDizzyMC Date: Sun, 21 Feb 2021 00:15:30 -0500 Subject: [PATCH] ShareX URL Delete compatibility --- delete.go | 8 ++++++-- put.icu.sxcu | 11 +++++++++++ server.go | 4 +++- 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 put.icu.sxcu diff --git a/delete.go b/delete.go index 38e36e3..b2d0ad7 100644 --- a/delete.go +++ b/delete.go @@ -10,9 +10,13 @@ import ( func deleteHandler(c web.C, w http.ResponseWriter, r *http.Request) { requestKey := r.Header.Get("Linx-Delete-Key") - + urlRequestKey := r.URL.Query().Get("linx-delete-key") + if len(urlRequestKey) > 0 { + requestKey := urlRequestKey + } + filename := c.URLParams["name"] - + // Ensure that file exists and delete key is correct metadata, err := storageBackend.Head(filename) if err == backends.NotFoundErr { diff --git a/put.icu.sxcu b/put.icu.sxcu new file mode 100644 index 0000000..99fa524 --- /dev/null +++ b/put.icu.sxcu @@ -0,0 +1,11 @@ +{ + "Version": "13.1.0", + "DestinationType": "ImageUploader, FileUploader", + "RequestMethod": "PUT", + "RequestURL": "https://put.icu/upload/", + "Headers": { + "Accept": "application/json" + }, + "Body": "Binary", + "URL": "$json:url$" +} \ No newline at end of file diff --git a/server.go b/server.go index 7c56639..fcce5ce 100644 --- a/server.go +++ b/server.go @@ -212,7 +212,9 @@ func setup() *web.Mux { mux.Put(Config.sitePath+"upload/:name", uploadPutHandler) mux.Delete(Config.sitePath+":name", deleteHandler) - + // Adding new delete path method to make linx-server usable with ShareX. + mux.Get(Config.sitePath+"delete/:name", deleteHandler) + mux.Get(Config.sitePath+"static/*", staticHandler) mux.Get(Config.sitePath+"favicon.ico", staticHandler) mux.Get(Config.sitePath+"robots.txt", staticHandler)