You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

examples.md 4.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. # Table of Contents
  2. * [Aliases](#aliases)
  3. * [Uploading and downloading](#uploading-and-downloading)
  4. * [Archiving and backups](#archiving-and-backups)
  5. * [Encrypting and decrypting](#encrypting-and-decrypting)
  6. * [Scanning for viruses](#scanning-for-viruses)
  7. ## Aliases
  8. <a name="aliases"/>
  9. ## Add alias to .bashrc or .zshrc
  10. ### Using curl
  11. ```bash
  12. transfer() {
  13. curl --progress-bar --upload-file "$1" https://transfer.sh/$(basename "$1") | tee /dev/null;
  14. echo
  15. }
  16. alias transfer=transfer
  17. ```
  18. ### Using wget
  19. ```bash
  20. transfer() {
  21. wget -t 1 -qO - --method=PUT --body-file="$1" --header="Content-Type: $(file -b --mime-type "$1")" https://transfer.sh/$(basename "$1");
  22. echo
  23. }
  24. alias transfer=transfer
  25. ```
  26. ## Add alias for fish-shell
  27. ### Using curl
  28. ```fish
  29. function transfer --description 'Upload a file to transfer.sh'
  30. if [ $argv[1] ]
  31. # write to output to tmpfile because of progress bar
  32. set -l tmpfile ( mktemp -t transferXXXXXX )
  33. curl --progress-bar --upload-file "$argv[1]" https://transfer.sh/(basename $argv[1]) >> $tmpfile
  34. cat $tmpfile
  35. command rm -f $tmpfile
  36. else
  37. echo 'usage: transfer FILE_TO_TRANSFER'
  38. end
  39. end
  40. funcsave transfer
  41. ```
  42. ### Using wget
  43. ```fish
  44. function transfer --description 'Upload a file to transfer.sh'
  45. if [ $argv[1] ]
  46. 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])
  47. else
  48. echo 'usage: transfer FILE_TO_TRANSFER'
  49. end
  50. end
  51. funcsave transfer
  52. ```
  53. Now run it like this:
  54. ```bash
  55. $ transfer test.txt
  56. ```
  57. ## Add alias on Windows
  58. Put a file called `transfer.cmd` somewhere in your PATH with this inside it:
  59. ```cmd
  60. @echo off
  61. setlocal
  62. :: use env vars to pass names to PS, to avoid escaping issues
  63. set FN=%~nx1
  64. set FULL=%1
  65. powershell -noprofile -command "$(Invoke-Webrequest -Method put -Infile $Env:FULL https://transfer.sh/$Env:FN).Content"
  66. ```
  67. ## Uploading and Downloading
  68. <a name="uploading-and-downloading"/>
  69. ### Uploading with wget
  70. ```bash
  71. $ wget --method PUT --body-file=/tmp/file.tar https://transfer.sh/file.tar -O - -nv
  72. ```
  73. ### Uploading with PowerShell
  74. ```posh
  75. PS H:\> invoke-webrequest -method put -infile .\file.txt https://transfer.sh/file.txt
  76. ```
  77. ### Upload using HTTPie
  78. ```bash
  79. $ http https://transfer.sh/ -vv < /tmp/test.log
  80. ```
  81. ### Uploading a filtered text file
  82. ```bash
  83. $ grep 'pound' /var/log/syslog | curl --upload-file - https://transfer.sh/pound.log
  84. ```
  85. ### Downloading with curl
  86. ```bash
  87. $ curl https://transfer.sh/1lDau/test.txt -o test.txt
  88. ```
  89. ### Downloading with wget
  90. ```bash
  91. $ wget https://transfer.sh/1lDau/test.txt
  92. ```
  93. ## Archiving and backups
  94. <a name="archiving-and-backups"/>
  95. ### Backup, encrypt and transfer a MySQL dump
  96. ```bash
  97. $ mysqldump --all-databases | gzip | gpg -ac -o- | curl -X PUT --upload-file "-" https://transfer.sh/test.txt
  98. ```
  99. ### Archive and upload directory
  100. ```bash
  101. $ tar -czf - /var/log/journal | curl --upload-file - https://transfer.sh/journal.tar.gz
  102. ```
  103. ### Uploading multiple files at once
  104. ```bash
  105. $ curl -i -F filedata=@/tmp/hello.txt -F filedata=@/tmp/hello2.txt https://transfer.sh/
  106. ```
  107. ### Combining downloads as zip or tar.gz archive
  108. ```bash
  109. $ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).tar.gz
  110. $ curl https://transfer.sh/(15HKz/hello.txt,15HKz/hello.txt).zip
  111. ```
  112. ### Transfer and send email with link (using an alias)
  113. ```bash
  114. $ transfer /tmp/hello.txt | mail -s "Hello World" user@yourmaildomain.com
  115. ```
  116. ## Encrypting and decrypting
  117. <a name="encrypting-and-decrypting"/>
  118. ### Encrypting files with password using gpg
  119. ```bash
  120. $ cat /tmp/hello.txt | gpg -ac -o- | curl -X PUT --upload-file "-" https://transfer.sh/test.txt
  121. ```
  122. ### Downloading and decrypting
  123. ```bash
  124. $ curl https://transfer.sh/1lDau/test.txt | gpg -o- > /tmp/hello.txt
  125. ```
  126. ### Import keys from [keybase](https://keybase.io/)
  127. ```bash
  128. $ keybase track [them] # Encrypt for recipient(s)
  129. $ cat somebackupfile.tar.gz | keybase encrypt [them] | curl --upload-file '-' https://transfer.sh/test.txt # Decrypt
  130. $ curl https://transfer.sh/sqUFi/test.md | keybase decrypt
  131. ```
  132. ## Scanning for viruses
  133. <a name="scanning-for-viruses"/>
  134. ### Scan for malware or viruses using Clamav
  135. ```bash
  136. $ wget http://www.eicar.org/download/eicar.com
  137. $ curl -X PUT --upload-file ./eicar.com https://transfer.sh/eicar.com/scan
  138. ```
  139. ### Upload malware to VirusTotal, get a permalink in return
  140. ```bash
  141. $ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/virustotal
  142. ```