# filebin a tiny http file drop in c. ## what it does filebin serves a small upload page at `/` and accepts `post /upload` requests. you can fetch files at `get /f/`, set ttl by form field or header value. expired files are removed by a background cleanup loop that runs on a timer. uploads can be password protected and require a password to fetch the file. ## build and run ```sh make ./filebin -p 8080 -m 16 -n 128 -s 100 -t 3d ``` then open `http://127.0.0.1:8080/`. ## flags - `-p ` set port - `-m ` max upload request size in mb - `-n ` max open clients - `-s ` storage cap in gb - `-t ` default ttl (like `1h`, `1d`, `3d`) - `-d` run in daemon mode - `-u ` drop privileges - `-c ` chroot ## limits - defaults are `-m 16`, `-n 128`, `-s 100`, `-t 3d` ## openrc example `/etc/init.d/filebin`: ```sh #!/sbin/openrc-run name="filebin" description="" command="/usr/local/bin/filebin" command_args="-p 8080 -m 64 -n 256 -s 200 -t 1d -u filebin:filebin -c /var/lib/filebin" command_background="yes" pidfile="/run/${RC_SVCNAME}.pid" depend() { need net } ``` then: ```sh chmod +x /etc/init.d/filebin rc-update add filebin default rc-service filebin start ``` ## curl examples ```sh curl -F "file=@somefile.txt" -F "ttl=1h" http://127.0.0.1:8080/upload ``` ### paste text via curl ```sh printf 'hello world\nthis is a paste\n' | \ curl -F 'file=@-;filename=paste.txt' -F 'ttl=1h' http://127.0.0.1:8080/upload ``` ### password protected upload set password on upload with form field: ```sh curl -F "file=@somefile.txt" -F "password=secret123" http://127.0.0.1:8080/upload ``` or set password with header: ```sh curl -H "x-filebin-password: secret123" -F "file=@somefile.txt" http://127.0.0.1:8080/upload ``` fetch a protected file with header: ```sh curl -H "x-filebin-password: secret123" http://127.0.0.1:8080/f/ ``` or query string: ```sh curl "http://127.0.0.1:8080/f/?pw=secret123" ```