Skip to content

Deploying transfer.sh

Introduction

transfer.sh is a simple, fast, and easy-to-use file sharing service that allows you to share files from the command line. Originally created as a public service, transfer.sh can be self-hosted to provide your own private file sharing infrastructure with complete control over your data.

The service is designed with simplicity in mind - upload a file and get a link. Files can be uploaded via curl, wget, or any HTTP client, making it perfect for developers and system administrators who work primarily in the terminal.

Key highlights of transfer.sh:

  • Command Line Friendly: Upload files directly from terminal using curl or wget
  • Web Interface: Simple web UI for browser-based uploads
  • Automatic Expiration: Files automatically expire after a configurable period
  • Download Limits: Set maximum download counts for shared files
  • Encryption Support: Client-side encryption for sensitive files
  • No Registration: No accounts needed to share files
  • Multiple Storage Backends: Support for local storage, S3, and other backends
  • Custom URLs: Generate memorable URLs for shared files
  • Virus Scanning: Optional ClamAV integration for security
  • Rate Limiting: Protect against abuse with configurable limits
  • Open Source: Fully open source and self-hostable

This guide walks through deploying transfer.sh on Klutch.sh using Docker, configuring storage, and setting up the service for production use.

Why Deploy transfer.sh on Klutch.sh

Deploying transfer.sh on Klutch.sh provides several advantages:

Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds transfer.sh without complex configuration. Push to GitHub, and your file sharing service deploys automatically.

Persistent Storage: Attach persistent volumes for uploaded files. Your shared files survive container restarts and redeployments.

HTTPS by Default: Klutch.sh provides automatic SSL certificates, ensuring secure file transfers.

GitHub Integration: Connect your configuration repository directly from GitHub. Updates trigger automatic redeployments.

Private File Sharing: Control who has access to your file sharing infrastructure, perfect for teams or organizations.

Custom Domains: Assign a custom domain for branded file sharing links.

Always-On Availability: Your file sharing service remains accessible 24/7 without managing your own hardware.

Prerequisites

Before deploying transfer.sh on Klutch.sh, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your transfer.sh configuration
  • Basic familiarity with Docker and containerization concepts
  • (Optional) A custom domain for your transfer.sh instance

Preparing Your Repository

To deploy transfer.sh on Klutch.sh, create a GitHub repository containing your Dockerfile.

Repository Structure

transfer-sh-deploy/
├── Dockerfile
└── .dockerignore

Creating the Dockerfile

Create a Dockerfile in the root of your repository:

FROM dutchcoders/transfer.sh:latest
# Set environment variables
ENV LISTENER=:8080
ENV BASEDIR=/data
ENV TEMP_PATH=/tmp
# File retention settings
ENV PURGE_DAYS=14
ENV PURGE_INTERVAL=1
# Maximum file size (in bytes)
ENV MAX_UPLOAD_SIZE=5368709120
# Expose the web interface port
EXPOSE 8080
# Start transfer.sh
CMD ["--provider", "local", "--basedir", "/data"]

Advanced Dockerfile with S3 Storage

For production deployments with S3-compatible storage:

FROM dutchcoders/transfer.sh:latest
# Set environment variables
ENV LISTENER=:8080
ENV TEMP_PATH=/tmp
# File retention settings
ENV PURGE_DAYS=${PURGE_DAYS:-14}
ENV PURGE_INTERVAL=1
# Maximum file size (5GB default)
ENV MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE:-5368709120}
# S3 configuration
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ENV BUCKET=${S3_BUCKET}
ENV S3_REGION=${S3_REGION}
ENV S3_ENDPOINT=${S3_ENDPOINT}
# Rate limiting
ENV RATE_LIMIT=100
EXPOSE 8080
CMD ["--provider", "s3"]

Creating the .dockerignore File

Create a .dockerignore file:

.git
.github
*.md
LICENSE
.gitignore
*.log
.DS_Store
.env
.env.local

Environment Variables Reference

VariableRequiredDefaultDescription
LISTENERNo:8080Address and port to listen on
BASEDIRNo/dataLocal storage directory
PURGE_DAYSNo14Days before files are deleted
PURGE_INTERVALNo1Hours between purge runs
MAX_UPLOAD_SIZENo5GBMaximum upload size in bytes
RATE_LIMITNo-Requests per minute limit
AWS_ACCESS_KEY_IDConditional-S3 access key (for S3 storage)
AWS_SECRET_ACCESS_KEYConditional-S3 secret key (for S3 storage)
BUCKETConditional-S3 bucket name
S3_REGIONConditional-S3 region

Deploying transfer.sh on Klutch.sh

Once your repository is prepared, follow these steps to deploy transfer.sh:

    Push Your Repository to GitHub

    Initialize your repository and push to GitHub. Ensure your Dockerfile is in the root of your repository.

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project. Give it a descriptive name like “transfer-sh” or “file-share”.

    Create a New App

    Within your project, create a new app. Connect your GitHub account if you haven’t already, then select the repository containing your transfer.sh Dockerfile.

    Configure HTTP Traffic

    transfer.sh serves its interface over HTTP. In the deployment settings:

    • Select HTTP as the traffic type
    • Set the internal port to 8080

    Set Environment Variables

    In the environment variables section, configure your desired settings:

    VariableValue
    PURGE_DAYS14 (or your preferred retention period)
    MAX_UPLOAD_SIZE5368709120 (5GB, adjust as needed)

    Attach Persistent Volumes

    Add the following volume for local storage:

    Mount PathRecommended SizePurpose
    /data50+ GBUploaded files storage
    /tmp10 GBTemporary upload storage

    Deploy Your Application

    Click Deploy to start the build process. Klutch.sh will:

    • Detect your Dockerfile automatically
    • Build the container image
    • Attach the persistent volumes
    • Start the transfer.sh container
    • Provision an HTTPS certificate

    Access transfer.sh

    Once deployment completes, access your transfer.sh instance at https://your-app-name.klutch.sh.

Using transfer.sh

Command Line Usage

Upload files using curl:

Terminal window
# Upload a file
curl --upload-file ./example.txt https://your-app-name.klutch.sh/example.txt
# Upload with a custom filename
curl --upload-file ./document.pdf https://your-app-name.klutch.sh/my-document.pdf
# Upload and set max downloads
curl --upload-file ./secret.txt -H "Max-Downloads: 1" https://your-app-name.klutch.sh/secret.txt
# Upload and set expiration (in days)
curl --upload-file ./temp.txt -H "Max-Days: 1" https://your-app-name.klutch.sh/temp.txt

Using wget

Terminal window
# Upload with wget
wget --method PUT --body-file=./example.txt https://your-app-name.klutch.sh/example.txt -O - -q

Web Interface

Access the web interface in your browser:

  1. Navigate to https://your-app-name.klutch.sh
  2. Drag and drop files or click to select
  3. Copy the generated link

Shell Aliases

Add convenient aliases to your shell configuration:

Terminal window
# Add to ~/.bashrc or ~/.zshrc
transfer() {
curl --progress-bar --upload-file "$1" "https://your-app-name.klutch.sh/$(basename "$1")" | tee /dev/null
}
# Usage: transfer myfile.txt

Encrypted Uploads

For sensitive files, encrypt before uploading:

Terminal window
# Encrypt and upload
cat secret.txt | gpg -ac -o- | curl -X PUT --upload-file "-" https://your-app-name.klutch.sh/secret.txt.gpg
# Download and decrypt
curl https://your-app-name.klutch.sh/abc123/secret.txt.gpg | gpg -o- > secret.txt

Advanced Configuration

Download Limits

Control how many times a file can be downloaded:

Terminal window
curl --upload-file ./file.txt -H "Max-Downloads: 5" https://your-app-name.klutch.sh/file.txt

Custom Expiration

Set per-file expiration:

Terminal window
curl --upload-file ./file.txt -H "Max-Days: 7" https://your-app-name.klutch.sh/file.txt

Combining Options

Apply multiple restrictions:

Terminal window
curl --upload-file ./sensitive.txt \
-H "Max-Downloads: 1" \
-H "Max-Days: 1" \
https://your-app-name.klutch.sh/sensitive.txt

Production Best Practices

Security Recommendations

  • Rate Limiting: Enable rate limiting to prevent abuse
  • File Size Limits: Set appropriate maximum file sizes
  • Encryption: Encourage client-side encryption for sensitive files
  • Monitoring: Monitor disk usage and upload patterns

Storage Management

  • Purge Settings: Configure appropriate retention periods
  • Volume Sizing: Allocate sufficient storage for your usage patterns
  • S3 Storage: Consider S3-compatible storage for scalability

Abuse Prevention

  • Rate Limiting: Implement rate limits per IP
  • File Type Restrictions: Consider restricting dangerous file types
  • Monitoring: Watch for unusual upload patterns

Troubleshooting Common Issues

Uploads Failing

Symptoms: curl returns errors when uploading.

Solutions:

  • Check file size against MAX_UPLOAD_SIZE
  • Verify sufficient disk space
  • Check deployment logs for errors

Files Not Accessible

Symptoms: Download links return 404 errors.

Solutions:

  • Verify the file hasn’t expired
  • Check download count limits
  • Confirm persistent volume is mounted correctly

Slow Uploads

Symptoms: Upload speeds are very slow.

Solutions:

  • Check available bandwidth
  • Verify sufficient resources allocated
  • Consider using S3 storage for larger files

Additional Resources

Conclusion

Deploying transfer.sh on Klutch.sh gives you a simple, powerful file sharing service with automatic builds, persistent storage, and secure HTTPS access. The command-line friendly design makes it perfect for developers and system administrators who need quick, easy file sharing without the complexity of full-featured cloud storage.

Whether you’re sharing configuration files with teammates, distributing builds, or just need a quick way to move files between systems, transfer.sh on Klutch.sh provides a reliable, self-hosted solution that you control completely.