⚡ Simple file uploading service written in go!
- Download binary from releases / build yourself using the go compiler.
- Run the binary, and define an
AUTHenvioronment variable, like so:
AUTH="user:pass" ./up
# or
AUTH="user:pass" go run .- Use ShareX, cURL or any other client
curl -F '[email protected]' -u "user:pass" up.simo.sh-
The user makes a
POSTrequest to server with both their file andBasic Authheaders containing the username and password -
The server checks if the username and password match the ones in the
AUTHenvironment variable -
The server does extra validation on the file
- is it <= 512 MiB?
- does it exist already? (calculates the SHA256 hash of the file and gets the k/v pair from etcd-io/bbolt)
- if yes, check the date of upload
- if it's been 95% of its calculated lifespan, reupload
- otherwise, return the link
- if yes, check the date of upload
-
Upload the file in the
files/directory, as well as add a randomly generated filename + SHA256 hash in etcd-io/bbolt, like so:sha256 hash of file -> filename # or d144c320286f5a2e20573aaa1193786e2b369d7ea26bea42583771a4b0236029 -> XVlBzgbaiC
-
Return the URL of the file
-
Every 24 hours, the server calculates the lifespan of every file uploaded using the formula and deletes any files that exceed that:
# shoutout to 0x0.st retention = min_age + (-max_age + min_age) * pow((file_size / max_size - 1), 3)
- Basic Auth
- Automatic deletion after N amount of days (size dependent)
- SHA256 hash to check for duplicates
- Reupload if the file is going to be deleted soon
- Dockerfile for "easy" daemonizing (super overkill, especially considering the portability of go, but it's the only thing I know /shrug - better option is simply to use systemd)
- Refactor with structs?
- Tests lol
- URL shortener