File upload service
mod | ||
config.scm | ||
foxbox.scm | ||
LICENSE | ||
README.md |
FoxBox
A file upload service inspired by [https://catbox.moe], written in Guile Scheme.
Usage
Start the server like so:
$ guile -L mod foxbox.scm \
--port 8080 \
--file-size-permanent "100MiB" \
--file-size-temporary "1GiB" \
--file-lifetime "72hr" \
--file-type-whitelist "image/png image/jpeg image/gif video/webm"
# There's also --file-type-blacklist; everything is allowed by default
Then you use it with the following commands:
## Upload `tezuka_rin.png` with default settings
## Try uploading as a permanent file if it fits within the size limit, or fall
## back to temporary hosting with the maximum lifetime, if it fits there instead
$ curl -X POST --data-binary '@tezuka_rin.png' \
http://localhost:8080
## Set the lifetime of the file to be 48 hours long (clamps to maximum allowed)
$ curl -X POST --data-binary '@tezuka_rin.png' \
http://localhost:8080?lifetime=48hr
## Require the access token in order to view
$ curl -X POST --data-binary '@tezuka_rin.png' \
http://localhost:8080?secret=supersecret
## Request a resource
$ curl http://localhost:8080/XXXXXX.png
## Request a resource with an access token
$ curl http://localhost:8080/XXXXXX.png?secret=supersecret
## Modify a resource
$ curl -X PATCH -H 'X-Token: XXXXXX' \
http://localhost:8080/XXXXXX.png?secret=supersecret
$ curl -X PATCH -H 'X-Token: XXXXXX' \
http://localhost:8080/XXXXXX.png?lifetime=30min
## Delete a resource
$ curl -X DELETE -H 'X-Token: XXXXXX' \
http://localhost:8080/XXXXXX.png
The response will contain the following headers:
Location
: The URL of the uploaded fileExpires
: The expiration date and time of the fileX-Token
: A token required to modify or delete uploads