#paste #pastebin #upload

bin+lib rustypaste

A minimal file upload/pastebin service

8 releases (4 breaking)

0.5.0 Oct 12, 2021
0.4.1 Sep 18, 2021
0.4.0 Aug 27, 2021
0.3.1 Aug 9, 2021
0.1.3 Jul 27, 2021

#52 in HTTP server

Download history 41/week @ 2021-07-23 25/week @ 2021-07-30 34/week @ 2021-08-06 11/week @ 2021-08-13 1/week @ 2021-08-20 17/week @ 2021-08-27 1/week @ 2021-09-10 22/week @ 2021-09-17 11/week @ 2021-09-24 25/week @ 2021-10-01 35/week @ 2021-10-08 24/week @ 2021-10-15

65 downloads per month

MIT license

917 lines

Rustypaste is a minimal file upload/pastebin service.

$ echo "some text" > awesome.txt

$ curl -F "file=@awesome.txt" https://paste.site.com

$ curl https://paste.site.com/safe-toad.txt
some text


  • File upload & URL shortening
    • supports basic HTTP authentication
    • random file names (optional)
      • pet name (e.g. capital-mosquito.txt)
      • alphanumeric string (e.g. yB84D2Dv.txt)
    • supports expiring links
    • supports one shot links (can only be viewed once)
    • guesses MIME types
      • supports overriding and blacklisting
    • no duplicate uploads (optional)
  • Single binary
  • Easy to deploy
  • No database
    • filesystem is used
  • Self-hosted
    • centralization is bad!
  • Written in Rust
    • blazingly fast!


From crates.io

cargo install rustypaste

Binary releases

See the available binaries on releases page.

Build from source

git clone https://github.com/orhun/rustypaste.git
cd rustypaste/
cargo build --release


The standalone command line tool (rpaste) is available here.


function rpaste() {
    curl -F "file=@$1" -H "Authorization: <auth_token>" "<server_address>"

* consider reading authorization headers from a file. (e.g. -H @rpaste_auth)

# upload a file
$ rpaste x.txt

# paste from stdin
$ rpaste -


$ curl -F "file=@x.txt" -H "expire:10min" "<server_address>"

(supported units: ns, us, ms, sec, min, hours, days, weeks, months, years)

One Shot

$ curl -F "oneshot=@x.txt" "<server_address>"

Cleaning Up Expired Files

$ find upload/ -maxdepth 2 -type f -iname "*.[0-9]*" -exec rm -v {} \;

URL Shortening

$ curl -F "url=https://example.com/some/long/url" "<server_address>"


To start the server:

$ rustypaste

If the configuration file is not found in the current directory, specify it via CONFIG environment variable:

$ CONFIG="$HOME/.rustypaste.toml" rustypaste

To enable basic HTTP auth, set the AUTH_TOKEN environment variable (via .env):

$ echo "AUTH_TOKEN=$(openssl rand -base64 16)" > .env
$ rustypaste

See config.toml for configuration options.


Following command can be used to run a container which is built from the Dockerfile in this repository:

$ docker run --rm -d \
  -v "$(pwd)/upload/":/app/upload \
  -v "$(pwd)/config.toml":/app/config.toml \
  --env-file "$(pwd)/.env" \
  -e "RUST_LOG=debug" \
  -p 8000:8000 \
  --name rustypaste \
  • uploaded files go into ./upload (on the host machine)
  • set the AUTH_TOKEN via -e or --env-file to enable auth

You can build this image using docker build -t rustypaste . command.

If you want to run the image using docker compose, simply run docker-compose up -d. (see docker-compose.yml)


Example server configuration with reverse proxy:

server {
    listen 80;
    location / {
        proxy_pass                         http://localhost:8000/;
        proxy_set_header Host              $host;
        proxy_set_header X-Forwarded-For   $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        add_header X-XSS-Protection        "1; mode=block";
        add_header X-Frame-Options         "sameorigin";
        add_header X-Content-Type-Options  "nosniff";

If you get a 413 Request Entity Too Large error during upload, set the max body size in nginx.conf:

http {
    # ...
    client_max_body_size 100M;


  • Support uploading files from given URL
  • Hot reload the configuration file


Pull requests are welcome!

Consider submitting your ideas via issues first. Also, see the roadmap and/or run the following command to see what is needed to be done:

$ grep -nr "TODO:" src/


All code is licensed under The MIT License.


~739K SLoC