Advertisement
v1ral_ITS

Transfer any file to shareable online link

Jun 2nd, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.46 KB | None | 0 0
  1.  
  2. #!/bin/bash
  3. if [ $# -eq 0 ]; then echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"
  4. return 1
  5. fi
  6. tmpfile=$( mktemp -t transferXXX )
  7. if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
  8. curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile
  9. else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile
  10. fi
  11. cat $tmpfile
  12. rm -f $tmpfile
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement