transfer.sh

repository·main·Indexed 12 days ago

https://github.com/dutchcoders/transfer.sh

A command-line tool and server implementation for fast file sharing via HTTP. It supports uploading files using curl, end-to-end encryption with gpg, and various storage backends including S3, Storj, Google Drive, and local storage. Features include configurable upload limits, VirusTotal integration, and automated TLS setup via Let's Encrypt.

Tokens
9.6K
Snippets
31
Records
35
Agent score
95%

What's inside transfer.sh

  1. Use link aliases for direct downloads and inline files

    main

    You can transform standard transfer.sh URLs into specialized link types:

    • Direct Download: Replace the base URL with /get/ to create a link that triggers a download immediately.
    • Inline File: Replace the base URL with /inline/ to serve the file content directly in the browser/client.
    Standard: https://transfer.sh/1lDau/test.txt
    Direct Download: https://transfer.sh/get/1lDau/test.txt
    Inline: https://transfer.sh/inline/1lDau/test.txt
  2. Upload files using various CLI tools

    main

    Transfer.sh supports standard HTTP PUT requests. You can upload files using curl, wget, httpie, or PowerShell.

    ### Using curl
    ```bash
    # Upload a specific file
    curl --upload-file /path/to/file https://transfer.sh/file.txt
    
    # Upload piped text (filtered content)
    grep 'pattern' /var/log/syslog | curl --upload-file - https://transfer.sh/pattern.log

    Using wget

    # Upload using PUT method
    wget --method PUT --body-file=/tmp/file.tar https://transfer.sh/file.tar -O - -nv

    Using PowerShell

    Invoke-WebRequest -Method put -Infile .\file.txt https://transfer.sh/file.txt

    Using HTTPie

    http https://transfer.sh/ -vv < /tmp/test.log
  3. Configure the Google Drive provider

    main

    To use Google Drive as a storage provider, you need to set up an OAuth Client ID and provide the necessary file paths.

    Required Options:

    • provider: Set to gdrive.
    • gdrive-client-json-filepath: Path to your downloaded Google OAuth Client JSON file.
    • gdrive-local-config-path: Directory where the local configuration will be saved.
    • basedir: The base directory for operations.

    Setup Steps:

    1. Create an OAuth Client ID at console.cloud.google.com.
    2. Download the JSON credentials file and store it in a safe directory.
    // Example usage via go run
    go run main.go --provider gdrive --basedir /tmp/ --gdrive-client-json-filepath /[credential_dir] --gdrive-local-config-path [directory_to_save_config]
  4. Install the basic transfer shell function

    main

    For a lightweight way to upload files or directories (which are automatically zipped) via curl, add this function to your .bashrc, .zshrc, or equivalent shell configuration file.

    Usage: transfer <file|directory> or transfer <file_name>

    Example:

    $ transfer hello.txt
    transfer() (if [ $# -eq 0 ]; then printf "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>\n">&2; return 1; fi; file_name=$(basename "$1"); if [ -t 0 ]; then file="$1"; if [ ! -e "$file" ]; then echo "$file: No such file or directory" >&2; return 1; fi; if [ -d "$file" ]; then cd "$file" || return 1; file_name="$file_name.zip"; set -- zip -r -q - .; else set -- cat "$file"; fi; else set -- cat; fi; url=$("$@" | curl --silent --show-error --progress-bar --upload-file "-" "https://transfer.sh/$file_name"); echo "$url"; )
  5. Set up TLS with custom certificates

    main

    To use your own SSL/TLS certificates, configure the following settings:

    1. Set tls-listener to :443.
    2. Enable force-https.
    3. Provide the path to your certificate via tls-cert-file.
    4. Provide the path to your private key via tls-private-key.
  6. Encrypt and decrypt files for transfer

    main

    For sensitive data, encrypt files locally before uploading. You can use gpg for symmetric encryption or keybase for recipient-based encryption. To decrypt, download the file and pipe it to the corresponding decryption tool.

    ### Using GPG (Symmetric)
    # Encrypt and upload
    ```bash
    gpg --armor --symmetric --output - /tmp/secret.txt | curl --upload-file - https://transfer.sh/secret.txt
    
    # Download and decrypt
    curl https://transfer.sh/ID/secret.txt | gpg --decrypt --output /tmp/secret.txt

    Using Keybase

    # Encrypt for specific users and upload
    cat backup.tar.gz | keybase encrypt [user] | curl --upload-file '-' https://transfer.sh/backup.tar.gz
    
    # Download and decrypt
    curl https://transfer.sh/ID/backup.tar.gz | keybase decrypt
  7. Archive and upload multiple files

    main

    You can upload directories by archiving them first (e.g., using tar or zip) or upload multiple files in a single request using multipart/form-data.

    ### Archive and upload a directory
    ```bash
    tar -czf - /path/to/dir | curl --upload-file - https://transfer.sh/dir.tar.gz

    Upload multiple files at once

    curl -i -F filedata=@/tmp/file1.txt -F filedata=@/tmp/file2.txt https://transfer.sh/

    Combine multiple URLs into a single archive download

    curl https://transfer.sh/(ID1/file1.txt,ID2/file2.txt).tar.gz
  8. Configure S3 storage provider

    main

    To use an AWS S3 bucket as the storage backend, you must provide the following configuration:

    • --provider s3
    • aws-access-key (or AWS_ACCESS_KEY)
    • aws-secret-key (or AWS_SECRET_KEY)
    • bucket (or BUCKET)
    • s3-region (or S3_REGION)

    If you specify the s3-region, the correct endpoint URL will be used automatically. For non-AWS S3 providers (like Minio), you must also specify a custom endpoint using the s3-endpoint parameter.