0.5.2: Change retrieve_file error code to 403 because 404 doesn't work for some reason lol

This commit is contained in:
Fijxu 2024-08-04 15:33:49 -04:00
parent 839bd717b3
commit 873b4a4f5a
Signed by: Fijxu
GPG key ID: 32C1DDF333EDA6A4
2 changed files with 15 additions and 3 deletions

View file

@ -3,8 +3,21 @@
Simple file uploader made on Crystal.
I'm making this to replace my current File uploader hosted on https://ayaya.beauty which uses https://github.com/nokonoko/uguu
## Features
- Temporary file file uploader like Uguu
- File deletion link (not available in frontend for now)
- Chatterino and ShareX support
- Low memory usage: Between 6MB at idle and 25MB if a file is being uploaded of retrieved. I will depend of your traffic.
## TODO
- ~~Add file size limit~~ ADDED
- Fix error when accessing `http://127.0.0.1:8080` with an empty DB.
- Better frontend...
- Better frontend...
- Disable file deletion if `delete_files_after_check_seconds` or `delete_files_after` is set to `0`
- Disable delete key if `delete_key_lenght` is `0`
- Exit if `filename_lenght` is `0`
- Disable file limit if `size_limit` is `0`
-

View file

@ -100,13 +100,12 @@ end
end
def retrieve_file(env)
puts env.params.url
begin
filename = SQL.query_one "SELECT filename FROM files WHERE filename = ?", env.params.url["filename"].to_s.split(".").first, as: String
extension = SQL.query_one "SELECT extension FROM files WHERE filename = ?", filename, as: String
send_file env, "#{CONFIG.files}/#{filename}#{extension}"
rescue
error404("This file does not exist")
error403("This file does not exist")
end
end