mirror of
https://github.com/dutchcoders/transfer.sh.git
synced 2024-11-29 23:50:18 +01:00
Add URL encoding to transfer function to handle whitespaces
Add URL encoding functionality to the `transfer` function in `README.md` so that file names with spaces can be uploaded correctly. Also, the code uses the `_urlencode` function written in Python. This commit includes changes to the following: - Update the `transfer` function to use `_urlencode` for encoding the file names as URL. - Add the `_urlencode` function to URL encode the file names. Note: This change improves the functionality of the `transfer` function by making it more usable.
This commit is contained in:
parent
e837849d44
commit
b337570079
1 changed files with 1 additions and 1 deletions
|
@ -243,7 +243,7 @@ You need to create an OAuth Client id from console.cloud.google.com, download th
|
||||||
### Bash and zsh (multiple files uploaded as zip archive)
|
### Bash and zsh (multiple files uploaded as zip archive)
|
||||||
##### Add this to .bashrc or .zshrc or its equivalent
|
##### Add this to .bashrc or .zshrc or its equivalent
|
||||||
```bash
|
```bash
|
||||||
transfer(){ if [ $# -eq 0 ];then echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>">&2;return 1;fi;if tty -s;then 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 - .)|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null,;else cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;else file_name=$1;curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;fi;}
|
transfer(){ if [ $# -eq 0 ];then echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>">&2;return 1;fi;if tty -s;then 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 - .)|curl --progress-bar --upload-file "-" "https://transfer.sh/$(_urlencode $file_name)"|tee /dev/null;else cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$(_urlencode $file_name)"|tee /dev/null;fi;else file_name=$1;curl --progress-bar --upload-file "-" "https://transfer.sh/$(_urlencode $file_name)"|tee /dev/null;fi;}; _urlencode () { python3 -c 'from sys import argv, stdin; from urllib.parse import quote; print(quote(argv[1] if argv[1:] else stdin.read()))' "$@" }
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Now you can use transfer function
|
#### Now you can use transfer function
|
||||||
|
|
Loading…
Reference in a new issue