### Using the Transfer Function Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Example of how to use the previously defined transfer function to upload a file named 'hello.txt'. ```bash $ transfer hello.txt ``` -------------------------------- ### Transfer File and Send Email with Link Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md This example first uploads '/tmp/hello.txt' using the 'transfer' command (likely an alias or script utilizing transfer.sh) and then pipes the resulting URL to the 'mail' command to send an email. ```bash $ transfer /tmp/hello.txt | mail -s "Hello World" user@yourmaildomain.com ``` -------------------------------- ### Google Drive Usage Example Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Command to upload files to Google Drive using transfer.sh. Requires specifying provider, base directory, and Google Drive credentials. ```bash main.go --provider gdrive --basedir /tmp/ --gdrive-client-json-filepath /[credential_dir] --gdrive-local-config-path [directory_to_save_config] ``` -------------------------------- ### Upload File with HTTPie Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md HTTPie provides a user-friendly way to upload files. This example uploads the content of '/tmp/test.log' to transfer.sh. ```bash $ http https://transfer.sh/ -vv < /tmp/test.log ``` -------------------------------- ### Example usage of transfer.sh alias Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Demonstrates how to invoke the transfer.sh alias after it has been set up in the shell. ```bash $ transfer test.txt ``` -------------------------------- ### Test transfer command for Windows download command Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Example of using the transfer command to upload a file and copy the Windows download command to the clipboard. ```sh $ transfer ~/temp/a.log w ######################################################################## 100.0% 1) Download link: https://transfer.sh/y0qr2c/a.log 2) Linux or macOS download command: wget https://transfer.sh/y0qr2c/a.log 3) Windows download command: Invoke-WebRequest -Uri https://transfer.sh/y0qr2c/a.log -OutFile a.log ``` -------------------------------- ### Upload File and Get URL/Deletion Token (Bash) Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md This script uploads a file to transfer.sh, prompts for download limits and expiry days, and saves the URL and deletion token to a file. It handles cases where the input file is not found. ```bash # tempfile URLFILE=$HOME/temp/transfersh.url # insert number of downloads and days saved if [ -f $1 ]; then read -p "Allowed number of downloads: " num_down read -p "Number of days on server: " num_save # transfer curl -sD - -H "Max-Downloads: $num_down" -H "Max-Days: $num_save"--progress-bar --upload-file $1 https://transfer.sh/$(basename $1) | grep -i -E 'transfer\.sh|x-url-delete' &> $URLFILE # display URL and deletion token if [ -f $URLFILE ]; then URL=$(tail -n1 $URLFILE) TOKEN=$(grep delete $URLFILE | awk -F "/" '{print $NF}') echo "*********************************" echo "Data is saved in $URLFILE" echo "**********************************" echo "URL is: $URL" echo "Deletion Token is: $TOKEN" echo "**********************************" else echo "NO URL-File found !!" fi else echo "!!!!!!" echo "\"$1\" not found !!" echo "!!!!!!" fi ``` -------------------------------- ### Get X-Url-Delete Header Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Use this command to retrieve the X-Url-Delete header, which contains the URL for file deletion. It also shows the direct upload URL. ```bash curl -sD - --upload-file ./hello.txt https://transfer.sh/hello.txt | grep -i -E 'transfer\.sh|x-url-delete' x-url-delete: https://transfer.sh/hello.txt/BAYh0/hello.txt/PDw0NHPcqU https://transfer.sh/hello.txt/BAYh0/hello.txt ``` -------------------------------- ### Import Keys and Upload Encrypted File with Keybase Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Demonstrates importing GPG keys using Keybase for encryption and then uploading an encrypted file. Requires Keybase to be set up. ```bash $ keybase track [them] # Encrypt for recipient(s) $ cat somebackupfile.tar.gz | keybase encrypt [them] | curl --upload-file '-' https://transfer.sh/test.txt # Decrypt ``` -------------------------------- ### Upload multiple files and display output Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Demonstrates uploading multiple files using a wildcard and displays the interactive prompt, progress, and generated delete/download links. ```bash $ ls -lh total 20M -rw-r--r-- 1 10M Apr 4 21:08 image.img -rw-r--r-- 1 10M Apr 4 21:08 image2.img $ transfer image* 10240K image2.img 10240K image.img 20480K total Do you really want to upload the above files (2) to "transfer.sh"? (Y/n): ######################################################################################################################################################################################################################################## 100.0% Delete command: curl --request DELETE "https://transfer.sh/wJw9pz/image2.img/mSctGx7pYCId" Delete token: mSctGx7pYCId Download link: https://transfer.sh/wJw9pz/image2.img ######################################################################################################################################################################################################################################## 100.0% Delete command: curl --request DELETE "https://transfer.sh/ljJc5I/image.img/nw7qaoiKUwCU" Delete token: nw7qaoiKUwCU Download link: https://transfer.sh/ljJc5I/image.img ``` -------------------------------- ### Upload a single file and parse output Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Shows how to upload a single file and use `awk` to extract only the delete token and download link from the output. ```bash $ transfer "image.img" | awk --field-separator=": " '/Delete token:/ { print $2 } /Download link:/ { print $2 }' 10240K image.img 10240K total Do you really want to upload the above files (1) to "transfer.sh"? (Y/n): ######################################################################################################################################################################################################################################## 100.0% tauN5dE3fWJe https://transfer.sh/MYkuqn/image.img ``` -------------------------------- ### Create Direct Download Link Alias Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Transform a standard transfer.sh URL into a direct download link by appending '/get'. ```text https://transfer.sh/1lDau/test.txt --> https://transfer.sh/get/1lDau/test.txt ``` -------------------------------- ### Configure Storj Network Provider Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Set up the Storj Network provider by specifying the access grant and bucket name. It is recommended to use environment variables for security. ```bash export STORJ_BUCKET= export STORJ_ACCESS= transfer.sh --provider storj ``` -------------------------------- ### Build transfer.sh Binary Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Clone the transfer.sh repository and build the executable binary. This is a standard Go build process. ```bash git clone git@github.com:dutchcoders/transfer.sh.git cd transfer.sh go build -o transfersh main.go ``` -------------------------------- ### Create Inline File Link Alias Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Transform a standard transfer.sh URL into an inline viewing link by appending '/inline'. ```text https://transfer.sh/1lDau/test.txt --> https://transfer.sh/inline/1lDau/test.txt ``` -------------------------------- ### Run transfer.sh Locally Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Execute the transfer.sh application locally using Go. This command specifies the local provider, the listener port, and temporary/base directories. ```bash go run main.go --provider=local --listener :8080 --temp-path=/tmp/ --basedir=/tmp/ ``` -------------------------------- ### Download and Decrypt File with Keybase Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Downloads a file from transfer.sh and decrypts it using Keybase's decryption utility. ```bash $ curl https://transfer.sh/sqUFi/test.md | keybase decrypt ``` -------------------------------- ### Upload File with wget Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Use wget to upload a file to transfer.sh. The --method PUT and --body-file options specify the upload action and the file to be uploaded. ```bash $ wget --method PUT --body-file=/tmp/file.tar https://transfer.sh/file.tar -O - -nv ``` -------------------------------- ### Run transfer.sh Docker Container (No Root) Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Deploy transfer.sh using the official Docker image with the '-noroot' tag. This runs the container with reduced privileges (UID/GID 5000) for enhanced security. ```bash docker run --publish 8080:8080 dutchcoders/transfer.sh:latest-noroot --provider local --basedir /tmp/ ``` -------------------------------- ### Archive and Upload Directory Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Compresses a directory using tar and gzip, then uploads the resulting archive to transfer.sh via curl. ```bash $ tar -czf - /var/log/journal | curl --upload-file - https://transfer.sh/journal.tar.gz ``` -------------------------------- ### Configure AWS S3 Provider Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Specify the AWS S3 provider and authentication details using flags or environment variables. Ensure bucket and region are correctly set. ```bash --provider s3 --aws-access-key --aws-secret-key --bucket --s3-region ``` -------------------------------- ### Run transfer.sh Docker Container (Root) Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Deploy transfer.sh using the official Docker image. This command runs the container with root privileges, publishing port 8080 and configuring the local provider with a base directory. ```bash docker run --publish 8080:8080 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/ ``` -------------------------------- ### Download File with wget Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Download a file from transfer.sh using wget. By default, wget saves the file with its original name. ```bash $ wget https://transfer.sh/1lDau/test.txt ``` -------------------------------- ### Upload File to VirusTotal for Analysis Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Uploads a file to transfer.sh with the '/virustotal' endpoint, which then submits the file to VirusTotal for analysis and returns a permalink. ```bash $ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/virustotal ``` -------------------------------- ### Upload file with download limit Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Limit the number of times a file can be downloaded by setting the 'Max-Downloads' header. This is useful for temporary access. ```bash $ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H "Max-Downloads: 1" # Limit the number of downloads ``` -------------------------------- ### Backup, Encrypt, and Transfer MySQL Dump Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md This command pipes a MySQL dump through gzip and gpg for compression and encryption, then uploads the result to transfer.sh using curl. ```bash $ mysqldump --all-databases | gzip | gpg -ac -o- | curl -X PUT --upload-file "-" https://transfer.sh/test.txt ``` -------------------------------- ### Upload File with PowerShell Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Upload a local file using PowerShell's Invoke-WebRequest cmdlet. Ensure the file path is correct for your system. ```powershell PS H:\> invoke-webrequest -method put -infile .\file.txt https://transfer.sh/file.txt ``` -------------------------------- ### Alias pbcopy and pbpaste for xsel Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md If using xsel on Linux, add these aliases to your shell configuration to enable clipboard functionality for pbcopy and pbpaste. ```sh alias pbcopy='xsel --clipboard --input' alias pbpaste='xsel --clipboard --output' ``` -------------------------------- ### Encrypt and Upload File Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Encrypts a local file using GPG with a password and uploads it to transfer.sh. The encrypted content is piped directly to curl. ```bash $ gpg --armor --symmetric --output - /tmp/hello.txt | curl --upload-file - https://transfer.sh/test.txt ``` -------------------------------- ### Configure Custom S3 Provider Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md For non-AWS S3 providers, specify the endpoint URL along with other S3 configuration options. ```bash --provider s3 --endpoint-url --aws-access-key --aws-secret-key --bucket ``` -------------------------------- ### Upload file with expiration date Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Set the number of days before a file is automatically deleted by using the 'Max-Days' header. This helps manage storage. ```bash $ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H "Max-Days: 1" # Set the number of days before deletion ``` -------------------------------- ### Add transfer.sh alias for fish-shell using wget Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md This fish shell function `transfer` uploads a file using wget. It dynamically determines the content type and uploads the file to transfer.sh. ```fish function transfer --description 'Upload a file to transfer.sh' if [ $argv[1] ] wget -t 1 -qO - --method=PUT --body-file="$argv[1]" --header="Content-Type: (file -b --mime-type $argv[1])" https://transfer.sh/(basename $argv[1]) else echo 'usage: transfer FILE_TO_TRANSFER' end end funcsave transfer ``` -------------------------------- ### Upload Multiple Files with curl Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Uploads two files, hello.txt and hello2.txt, simultaneously to transfer.sh using curl's '-F' option for multipart form data. ```bash $ curl -i -F filedata=@/tmp/hello.txt -F filedata=@/tmp/hello2.txt https://transfer.sh/ ``` -------------------------------- ### Upload a file using curl Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Use this command to upload a local file to transfer.sh. The URL will contain the filename. ```bash $ curl --upload-file ./hello.txt https://transfer.sh/hello.txt ``` -------------------------------- ### Download File with curl Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Download a file from transfer.sh using curl and save it to 'test.txt'. The '-o' flag specifies the output filename. ```bash $ curl https://transfer.sh/1lDau/test.txt -o test.txt ``` -------------------------------- ### Alias pbcopy and pbpaste for xclip Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md If using xclip on Linux, add these aliases to your shell configuration to enable clipboard functionality for pbcopy and pbpaste. ```sh alias pbcopy='xclip -selection clipboard' alias pbpaste='xclip -selection clipboard -o' ``` -------------------------------- ### Transfer.sh Shell Function for Upload and Copy Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md This shell function uploads a file using curl and pipes the download URL to pbcopy. It also displays download commands for Linux/macOS and Windows, optionally copying one to the clipboard based on the second argument. ```sh transfer() { curl --progress-bar --upload-file "$1" https://transfer.sh/$(basename "$1") | pbcopy; echo "1) Download link:" echo "$(pbpaste)" echo "\n2) Linux or macOS download command:" linux_macos_download_command="wget $(pbpaste)" echo $linux_macos_download_command echo "\n3) Windows download command:" windows_download_command="Invoke-WebRequest -Uri \"$(pbpaste)\" -OutFile $(basename $1)" echo $windows_download_command case $2 in l|m) echo $linux_macos_download_command | pbcopy ;; w) echo $windows_download_command | pbcopy ;; esac } ``` -------------------------------- ### Build Custom transfer.sh Docker Container Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Build a custom Docker image for transfer.sh, allowing specification of the user ID (PUID) and group ID (PGID). This is useful for scenarios like NFS mounts. ```bash # Build arguments: # * RUNAS: If empty, the container will run as root. # Set this to anything to enable UID/GID selection. # * PUID: UID of the process. Needs RUNAS != "". Defaults to 5000. # * PGID: GID of the process. Needs RUNAS != "". Defaults to 5000. docker build -t transfer.sh-noroot --build-arg RUNAS=doesntmatter --build-arg PUID=1337 --build-arg PGID=1338 . ``` -------------------------------- ### Delete a file using the X-Url-Delete header Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Use the delete URL provided in the X-Url-Delete response header to remove a file from transfer.sh. ```bash $ curl -X DELETE ``` -------------------------------- ### Download and Decrypt File Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Downloads an encrypted file from transfer.sh using curl and decrypts it using GPG. The decrypted content is saved to a local file. ```bash $ curl https://transfer.sh/1lDau/test.txt | gpg --decrypt --output /tmp/hello.txt ``` -------------------------------- ### Upload Filtered Text with curl Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md This command pipes the output of 'grep' to curl, uploading only the lines containing 'pound' from syslog to transfer.sh. ```bash $ grep 'pound' /var/log/syslog | curl --upload-file - https://transfer.sh/pound.log ``` -------------------------------- ### Download Multiple Files as Archive with curl Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Downloads multiple files specified by their transfer.sh IDs and combines them into a single archive. Supports both .tar.gz and .zip formats. ```bash $ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).tar.gz ``` ```bash $ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).zip ``` -------------------------------- ### Scan Uploaded File for Viruses Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Downloads a test EICAR virus file and uploads it to transfer.sh with the '/scan' endpoint to trigger a virus scan. This is for testing purposes. ```bash $ wget http://www.eicar.org/download/eicar.com $ curl -X PUT --upload-file ./eicar.com https://transfer.sh/eicar.com/scan ``` -------------------------------- ### Add transfer.sh alias to .bashrc or .zshrc using wget Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md This snippet defines a bash function `transfer` for uploading files using wget and then creates an alias for it. It sets the method to PUT and dynamically determines the content type. ```bash transfer() { wget -t 1 -qO - --method=PUT --body-file="$1" --header="Content-Type: $(file -b --mime-type "$1")" https://transfer.sh/$(basename "$1"); echo } alias transfer=transfer ``` -------------------------------- ### Server-side decryption download Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Decrypt file content server-side using AES256 with a specified password by setting the 'X-Decrypt-Password' header. This requires a self-hosted instance. ```bash $ curl https://your-transfersh-instance.tld/BAYh0/hello.txt -H "X-Decrypt-Password: test" # Decrypt the content server side with AES256 using "test" as password ``` -------------------------------- ### Server-side encryption upload Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md Encrypt file content server-side using AES256 with a specified password by setting the 'X-Encrypt-Password' header. Use with caution on self-hosted instances. ```bash $ curl --upload-file ./hello.txt https://your-transfersh-instance.tld/hello.txt -H "X-Encrypt-Password: test" # Encrypt the content server side with AES256 using "test" as password ``` -------------------------------- ### Add Alias on Windows Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md This script adds a transfer.sh alias to your Windows PATH. It uses PowerShell to handle the upload, passing filenames via environment variables to avoid shell escaping issues. ```cmd @echo off setlocal :: use env vars to pass names to PS, to avoid escaping issues set FN=%~nx1 set FULL=%1 powershell -noprofile -command "$(Invoke-Webrequest -Method put -Infile $Env:FULL https://transfer.sh/$Env:FN).Content" ``` -------------------------------- ### Bash/Zsh Script for transfer.sh Upload Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md This script facilitates file uploads to transfer.sh. It prompts for confirmation before uploading and extracts delete URLs and tokens from the response. Add this to your .bashrc or .zshrc. ```bash transfer() { local file declare -a file_array file_array=("${@}") if [[ "${file_array[@]}" == "" || "${1}" == "--help" || "${1}" == "-h" ]] then echo "${0} - Upload arbitrary files to \"transfer.sh\"." echo "" echo "Usage: ${0} [options] []..." echo "" echo "OPTIONS:" echo " -h, --help" echo " show this message" echo "" echo "EXAMPLES:" echo " Upload a single file from the current working directory:" echo " ${0} \"image.img\"" echo "" echo " Upload multiple files from the current working directory:" echo " ${0} \"image.img\" \"image2.img\"" echo "" echo " Upload a file from a different directory:" echo " ${0} \"/tmp/some_file\"" echo "" echo " Upload all files from the current working directory. Be aware of the webserver's rate limiting!: echo " ${0} *" echo "" echo " Upload a single file from the current working directory and filter out the delete token and download link:" echo " ${0} \"image.img\" | awk --field-separator=\": \" '/Delete token:/ { print \$2 } /Download link:/ { print \$2 }'" echo "" echo " Show help text from \"transfer.sh\":" echo " curl --request GET \"https://transfer.sh\"" return 0 else for file in "${file_array[@]}" do if [[ ! -f "${file}" ]] then echo -e "\e[01;31m'${file}' could not be found or is not a file.\e[0m" >&2 return 1 fi done unset file fi local upload_files local curl_output local awk_output du -c -k -L "${file_array[@]}" >&2 # be compatible with "bash" if [[ "${ZSH_NAME}" == "zsh" ]] then read $'upload_files?\e[01;31mDo you really want to upload the above files ('"${#file_array[@]}"$") to \"transfer.sh\"? (Y/n): \e[0m' elif [[ "${BASH}" == *"bash"* ]] then read -p $'$\e[01;31mDo you really want to upload the above files ('"${#file_array[@]}"$") to \"transfer.sh\"? (Y/n): \e[0m' upload_files fi case "${upload_files:-y}" in "y"|"Y") # for the sake of the progress bar, execute "curl" for each file. # the parameters "--include" and "--form" will suppress the progress bar. for file in "${file_array[@]}" do # show delete link and filter out the delete token from the response header after upload. # it is important to save "curl's" "stdout" via a subshell to a variable or redirect it to another command, # which just redirects to "stdout" in order to have a sane output afterwards. # the progress bar is redirected to "stderr" and is only displayed, # if "stdout" is redirected to something; e.g. ">/dev/null", "tee /dev/null" or "| ". # the response header is redirected to "stdout", so redirecting "stdout" to "/dev/null" does not make any sense. # redirecting "curl's" "stderr" to "stdout" ("2>&1") will suppress the progress bar. curl_output=$(curl --request PUT --progress-bar --dump-header - --upload-file "${file}" "https://transfer.sh/") awk_output=$(awk \ 'gsub("\r", "", $0) && tolower($1) ~ /x-url-delete/ \ { delete_link=$2; print "Delete command: curl --request DELETE " \"delete_link\" ";" gsub(".*/", "", delete_link); delete_token=delete_link; print "Delete token: " delete_token; } END print "Download link: " $0; }' <<< "${curl_output}") # return the results via "stdout", "awk" does not do this for some reason. echo -e "${awk_output}\n" # avoid rate limiting as much as possible; nginx: too many requests. if (( ${#file_array[@]} > 4 )) then sleep 5 fi done ;; "n"|"N") return 1 ;; *) echo -e "\e[01;31mWrong input: '${upload_files}'.\e[0m" >&2 return 1 esac } ``` -------------------------------- ### Human Readable Bash Function for Encrypted Upload Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md A more readable version of the bash function for encrypting and uploading files/directories. It includes error handling and supports setting a maximum download limit. ```bash transfer-encrypted() { if [ $# -eq 0 ]; then echo "No arguments specified.\nUsage:\n transfer \n ... | transfer " >&2 return 1 fi while getopts ":D:" opt; do case $opt in D) max_downloads=$OPTARG ;; \?) echo "Invalid option: -$OPTARG" >&2 ;; esac done shift "$((OPTIND - 1))" file="$1" file_name=$(basename "$file") if [ ! -e "$file" ]; then echo "$file: No such file or directory" >&2 return 1 fi if [ -d "$file" ]; then file_name="$file_name.zip" (cd "$file" && zip -r -q - .) | openssl aes-256-cbc -pbkdf2 -e > "tmp-$file_name" && cat "tmp-$file_name" | curl -H "Max-Downloads: $max_downloads" -w '\n' --upload-file "tmp-$file_name" "https://transfer.sh/$file_name" | tee /dev/null rm "tmp-$file_name" else cat "$file" | openssl aes-256-cbc -pbkdf2 -e > "tmp-$file" && cat "tmp-$file" | curl -H "Max-Downloads: $max_downloads" -w '\n' --upload-file - "https://transfer.sh/$file_name" | tee /dev/null rm "tmp-$file" fi } ``` -------------------------------- ### Add transfer.sh alias to .bashrc or .zshrc using curl Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md This snippet defines a bash function `transfer` for uploading files using curl and then creates an alias for it. It displays a progress bar and pipes the output to tee to avoid buffering. ```bash transfer() { curl --progress-bar --upload-file "$1" https://transfer.sh/$(basename "$1") | tee /dev/null; echo } alias transfer=transfer ``` -------------------------------- ### Add transfer.sh alias for fish-shell using curl Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md This fish shell function `transfer` uploads a file using curl, displaying a progress bar. It writes output to a temporary file to handle the progress bar correctly and then cleans up the temporary file. ```fish function transfer --description 'Upload a file to transfer.sh' if [ $argv[1] ] # write to output to tmpfile because of progress bar set -l tmpfile ( mktemp -t transferXXXXXX ) curl --progress-bar --upload-file "$argv[1]" https://transfer.sh/(basename $argv[1]) >> $tmpfile cat $tmpfile command rm -f $tmpfile else echo 'usage: transfer FILE_TO_TRANSFER' end end funcsave transfer ``` -------------------------------- ### Decrypt Uploaded Password Protected File Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md Downloads an encrypted file from transfer.sh and decrypts it using OpenSSL AES-256-CBC with PBKDF2. The decrypted content is piped to standard output and can be redirected to a file. ```bash curl -s https://transfer.sh/some/file | openssl aes-256-cbc -pbkdf2 -d > output_filename ``` -------------------------------- ### Bash Function for Encrypted Upload with Max Downloads Source: https://github.com/dutchcoders/transfer.sh/blob/main/examples.md A bash function to encrypt files or directories using OpenSSL AES-256-CBC and upload them to transfer.sh. It supports specifying a maximum number of downloads using the -D flag. ```bash transfer-encrypted() { if [ $# -eq 0 ]; then echo "No arguments specified.\nUsage:\n transfer \n ... | transfer " >&2; return 1; fi; while getopts ":D:" opt; do case $opt in D) max_downloads=$OPTARG;; \?) echo "Invalid option: -$OPTARG" >&2;; esac; done; shift "$((OPTIND - 1))"; file="$1"; file_name=$(basename "$file"); if [ ! -e "$file" ]; then echo "$file: No such file or directory" >&2; return 1; fi; if [ -d "$file" ]; then file_name="$file_name.zip"; (cd "$file" && zip -r -q - .) | openssl aes-256-cbc -pbkdf2 -e > "tmp-$file_name" && cat "tmp-$file_name" | curl -H "Max-Downloads: $max_downloads" -w '\n' --upload-file "tmp-$file_name" "https://transfer.sh/$file_name" | tee /dev/null; rm "tmp-$file_name"; else cat "$file" | openssl aes-256-cbc -pbkdf2 -e > "tmp-$file" && cat "tmp-$file" | curl -H "Max-Downloads: $max_downloads" -w '\n' --upload-file - "https://transfer.sh/$file_name" | tee /dev/null; rm "tmp-$file"; fi; } ``` -------------------------------- ### Bash/Zsh Transfer Function Source: https://github.com/dutchcoders/transfer.sh/blob/main/README.md A shell function for bash, ash, and zsh to upload single files or directories (as zip archives) using transfer.sh. Add this to your .bashrc or .zshrc. It handles no arguments, non-existent files, and directory uploads. ```bash transfer() (if [ $# -eq 0 ]; then printf "No arguments specified.\nUsage:\n transfer \n ... | transfer \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"; ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.