Skip to content

Instantly share code, notes, and snippets.

@shaybensasson
Last active October 17, 2022 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaybensasson/6a32748222a41be90a7e783d1a7d950e to your computer and use it in GitHub Desktop.
Save shaybensasson/6a32748222a41be90a7e783d1a7d950e to your computer and use it in GitHub Desktop.
Bash script that uploads a file or a zipped directory to keep.sh
#!/bin/sh
# A script with functions to add to .bashrc
# Uploads a file or a zipped directory to `keep.sh`
# see https://free.keep.sh
# usage: transfer hello.txt
# requirements: curl
# based on transfer.sh old, not-working anymore script.
# A free bucket is provided by keep.sh for public use. Files are limited to 500MB and are deleted 24 hours after upload.
transfer() {
if [ $# -eq 0 ]; then
echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>" >&2
return 1
fi
file="$1"
file_name=$(basename "$file")
if [ -d "$file" ]; then # True if the FILE exists and is a directory.
file_name="$file_name.zip"
(cd "$file" && zip -r "../$file_name" .) && curl --progress-bar --upload-file "$file_name" "https://free.keep.sh"
else
curl --progress-bar --upload-file "-" "https://free.keep.sh"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment