A minimal file upload/pastebin service.
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Orhun Parmaksız d4d8a28783
chore(release): prepare for v0.10.0
3 days ago
.github feat(deps): allow using openssl for tls (#37) 2 weeks ago
examples docs(example): add information about using HTML form (#51) 3 days ago
extra/systemd chore(systemd): add systemd service files (#22) 1 year ago
fixtures feat(server): support one shot URLs (#46) 5 days ago
img docs(readme): add README.md 2 years ago
shuttle feat(server): allow configuring the content type for landing page (#48) 6 days ago
src chore(log): add startup log for showing the server address 3 days ago
.dockerignore docs(example): add information about using HTML form (#51) 3 days ago
.env refactor(server): use .env for auth token 2 years ago
.gitignore test(fixtures): add a test framework along with test fixtures 1 year ago
CHANGELOG.md chore(release): prepare for v0.10.0 3 days ago
Cargo.lock chore(release): prepare for v0.10.0 3 days ago
Cargo.toml chore(release): prepare for v0.10.0 3 days ago
Dockerfile chore(docker): enable dependency caching in Dockerfile 3 weeks ago
LICENSE docs(license): update copyright years 5 months ago
README.md docs(readme): add link to the blog post 3 days ago
codecov.yml chore(codecov): add codecov config (#21) 1 year ago
config.toml feat(server): allow configuring the content type for landing page (#48) 6 days ago
docker-compose.yml chore(docker): share the config file between host and container 2 years ago


GitHub Release Crate Release Coverage Continuous Integration Continuous Deployment Docker Builds Documentation

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

The public instance is available at https://rustypaste.shuttleapp.rs 🚀

Here you can read the blog post about how it is deployed on Shuttle: https://blog.orhun.dev/blazingly-fast-file-sharing

Table of Contents


  • File upload & URL shortening & upload from URL
    • supports basic HTTP authentication
    • random file names (optional)
      • pet name (e.g. capital-mosquito.txt)
      • alphanumeric string (e.g. yB84D2Dv.txt)
    • supports expiring links
      • auto-expiration of files (optional)
      • auto-deletion of expired files (optional)
    • supports one shot links/URLs (can only be viewed once)
    • guesses MIME types
      • supports overriding and blacklisting
      • supports forcing to download via ?download=true
    • no duplicate uploads (optional)
  • Single binary
  • Simple configuration
    • supports hot reloading
  • Easy to deploy
  • No database
    • filesystem is used
  • Self-hosted
    • centralization is bad!
  • Written in Rust
    • blazingly fast!


From crates.io

cargo install rustypaste

Arch Linux

pacman -S rustypaste

Alpine Linux

rustypaste is available for Alpine Edge. It can be installed via apk after enabling the testing repository.

apk add rustypaste

Binary releases

See the available binaries on the releases page.

Build from source

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

Feature flags

  • shuttle: enable an entry point for deploying on Shuttle
  • openssl: use distro OpenSSL (binary size is reduced ~20% in release mode)
  • rustls: use rustls (enabled as default)

To enable a feature for build, pass --features flag to cargo build command.

For example, to reuse the OpenSSL present on a distro already:

cargo build --release --no-default-features --features openssl


Unit tests
cargo test -- --test-threads 1
Test Fixtures


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 files

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

One shot URLs

$ curl -F "oneshot_url=https://example.com" "<server_address>"

URL shortening

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

Paste file from remote URL

$ curl -F "remote=https://example.com/file.png" "<server_address>"

Cleaning up expired files

Configure delete_expired_files to set an interval for deleting the expired files automatically.

On the other hand, following script can be used as cron for cleaning up the expired files manually:

#!/bin/env sh
now=$(date +%s)
find upload/ -maxdepth 2 -type f -iname "*.[0-9]*" |
while read -r filename; do
	[ "$(( ${filename##*.} / 1000 - "${now}" ))" -lt 0 ] && rm -v "${filename}"


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.


It is possible to use an HTML form for uploading files. To do so, you need to update two fields in your config.toml:

  • Set the landing_page_content_type to text/html; charset=utf-8.
  • Update the landing_page field with your HTML form.

For an example, see examples/html_form.toml


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;


Pull requests are welcome!

Consider submitting your ideas via issues first and check out the existing issues.


All code is licensed under The MIT License.