From e65777f61202b14b898569b8fd4758b2efdfc256 Mon Sep 17 00:00:00 2001 From: AndcoolSystems Date: Sun, 28 Jan 2024 14:58:30 +0300 Subject: [PATCH] created uploaders page, changed file delete method to GET --- README.md | 2 +- main.py | 3 ++- web/index.html | 3 ++- web/login/index.html | 3 ++- web/script.js | 2 +- web/tos/index.html | 3 ++- web/uploaders/File uploader.sxcu | 15 +++++++++++++++ web/uploaders/index.html | 31 +++++++++++++++++++++++++++++++ web/uploaders/style.css | 14 ++++++++++++++ 9 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 web/uploaders/File uploader.sxcu create mode 100644 web/uploaders/index.html create mode 100644 web/uploaders/style.css diff --git a/README.md b/README.md index ed6e3ab..fae6c96 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Upon successful execution, the API returns a `200` status code along with a JSON | 400 | Bad file extension | The file does not have an extension | | 413 | File size exceeds the limit (100MB) | The file size exceeds 100MB | -`DELETE /api/delete/?key=` — Deletes a file.
+`GET /api/delete/?key=` — Deletes a file.
Successful execution returns a `200` status code, removing the file from the server.
#### Possible Errors diff --git a/main.py b/main.py index a97c680..30cc989 100644 --- a/main.py +++ b/main.py @@ -168,7 +168,7 @@ async def send_file(url: str, request: Request): return FileResponse(path=result.filename, filename=result.user_filename, media_type=result.type) # Send file as FileResponse -@app.delete("/api/delete/{url}") # File delete handler +@app.get("/api/delete/{url}") # File delete handler async def delete_file(url: str, key: str = ""): result = await db.file.find_first(where={"url": url}) # Get file record by url if not result: return JSONResponse(content={"status": "error", "message": "File not found"}, status_code=200) # if file does'n exists @@ -186,6 +186,7 @@ async def delete_file(url: str, key: str = ""): else: # If provided key doesn't matched with key from database record return JSONResponse(content={"status": "error", "message": "invalid unique key"}, status_code=400) + @app.get("/api/getFiles") # get files handler @limiter.limit(f"10/minute") async def getFiles(request: Request, diff --git a/web/index.html b/web/index.html index 4fad3da..f4ebb4b 100644 --- a/web/index.html +++ b/web/index.html @@ -45,9 +45,10 @@

File uploader


diff --git a/web/login/index.html b/web/login/index.html index 4b5197d..e7fc368 100644 --- a/web/login/index.html +++ b/web/login/index.html @@ -26,8 +26,9 @@

File uploader


diff --git a/web/script.js b/web/script.js index 0b7bc38..6a15d23 100644 --- a/web/script.js +++ b/web/script.js @@ -6,7 +6,7 @@ let api_url = "https://fu.andcool.ru"; async function delete_file(data, id){ let confirmed = confirm("Delete it? It will be impossible to restore the file!"); if (confirmed){ - let response = await axios.delete(api + "/api/delete/" + data.file_url + "?key=" + data.key); + let response = await axios.get(api + "/api/delete/" + data.file_url + "?key=" + data.key); if (response.status == 200){ if (!data.synced){ let old_data = JSON.parse(localStorage.getItem("file_history") || "[]"); diff --git a/web/tos/index.html b/web/tos/index.html index ccbdb6a..fd97628 100644 --- a/web/tos/index.html +++ b/web/tos/index.html @@ -16,7 +16,8 @@

File uploader


diff --git a/web/uploaders/File uploader.sxcu b/web/uploaders/File uploader.sxcu new file mode 100644 index 0000000..d030048 --- /dev/null +++ b/web/uploaders/File uploader.sxcu @@ -0,0 +1,15 @@ +{ + "Version": "15.0.0", + "Name": "File uploader", + "DestinationType": "ImageUploader, FileUploader", + "RequestMethod": "POST", + "RequestURL": "https://fu.andcool.ru/api/upload", + "Parameters": { + "include_ext": "true" + }, + "Body": "MultipartFormData", + "FileFormName": "file", + "URL": "{json:file_url_full}", + "DeletionURL": "https://fu.andcool.ru/api/delete/{json:file_url}?key={json:key}", + "ErrorMessage": "{json:message}" +} \ No newline at end of file diff --git a/web/uploaders/index.html b/web/uploaders/index.html new file mode 100644 index 0000000..b2f82b0 --- /dev/null +++ b/web/uploaders/index.html @@ -0,0 +1,31 @@ + + + + + File uploader + + + + + + + + + + +
+

File uploader

+ +
+

by AndcoolSystems

+

ShareX

+

Click here to download the ShareX config

+ +
+ + \ No newline at end of file diff --git a/web/uploaders/style.css b/web/uploaders/style.css new file mode 100644 index 0000000..5e51d23 --- /dev/null +++ b/web/uploaders/style.css @@ -0,0 +1,14 @@ +h2{ + margin-bottom: 1%; +} + +#sharex{ + margin: 0%; + margin-left: 15px; +} + +#sharex a{ + color:white; + text-decoration: underline; + +}