dutchcoders / transfer.sh

Easy and fast file sharing from the command-line.
https://github.com/dutchcoders/transfer.sh
MIT License
15.09k stars 1.54k forks source link

Add URL encoding to transfer function to handle whitespaces #548

Open snowphone opened 1 year ago

snowphone commented 1 year ago

Add URL encoding functionality to the transfer function in README.md so that file names with spaces can be uploaded correctly (e.g. hello world.json).

Also, the code uses the _urlencode function written in Python3. I know not every *nix OS includes Python3 by default but I'm familiar with Python and I don't know how to make it more portable.

This commit includes changes to the following:

Since this oneliner is too hard to review, I uploaded formatted code too: before.txt after.txt

If this PR is okay, I'll make a PR to tranfer.sh-web too

aspacca commented 1 year ago

hi @snowphone , thanks for the PR

please, see my comment at https://github.com/dutchcoders/transfer.sh/issues/546#issuecomment-1528347712

the best solution would be to avoid cat and do not add the filename in the url

cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"

vs

curl --progress-bar --upload-file "$file" "https://transfer.sh/"

so no need for urlencode and $file_name

snowphone commented 1 year ago

Wow it's too simple 😂 I changed this PR as you advised.