Not uploading files when filename has Spaces #397

Closed
opened 2026-01-19 18:30:10 +00:00 by michael · 3 comments
Owner

Originally created by @thibmaek on GitHub.

I'm getting upload errors when trying to upload a file with spaces, even when correctly escaping the spaces with a backslash.

Example: transfer Getting\ Started\ With\ Git.pdf

Errors when trying the above command:

curl: Can't open 'Getting'!
curl: try 'curl --help' or 'curl --manual' for more information

curl: (6) Could not resolve host: With

curl: (6) Could not resolve host: Git.png
######################################################################## 100.0%

curl: (6) Could not resolve host: Started

curl: (6) Could not resolve host: With

curl: (6) Could not resolve host: Git.png
Not Found
Originally created by @thibmaek on GitHub. I'm getting upload errors when trying to upload a file with spaces, even when correctly escaping the spaces with a backslash. **Example:** `transfer Getting\ Started\ With\ Git.pdf` Errors when trying the above command: ``` curl: Can't open 'Getting'! curl: try 'curl --help' or 'curl --manual' for more information curl: (6) Could not resolve host: With curl: (6) Could not resolve host: Git.png ######################################################################## 100.0% curl: (6) Could not resolve host: Started curl: (6) Could not resolve host: With curl: (6) Could not resolve host: Git.png Not Found ```
Author
Owner

@thibmaek commented on GitHub:

That seems to work but now I'm receiving all the HTTP headers in my Terminal window.

schermafdruk 2014-11-13 00 14 29

@thibmaek commented on GitHub: That seems to work but now I'm receiving all the HTTP headers in my Terminal window. ![schermafdruk 2014-11-13 00 14 29](https://cloud.githubusercontent.com/assets/6213695/5020492/2d1b6618-6aca-11e4-9767-42be86466390.png)
Author
Owner

@nl5887 commented on GitHub:

Great. The verbosity is easily fixed, just remove the -vvv.

transfer() {
    tmpfile=$( mktemp -t transferXXX )
    basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9]/-/g')
    curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile;
    cat $tmpfile;
    rm -f $tmpfile;
}

alias transfer=transfer
@nl5887 commented on GitHub: Great. The verbosity is easily fixed, just remove the -vvv. ``` transfer() { tmpfile=$( mktemp -t transferXXX ) basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9]/-/g') curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; cat $tmpfile; rm -f $tmpfile; } alias transfer=transfer ```
Author
Owner

@nl5887 commented on GitHub:

Try this:

transfer() {
    tmpfile=$( mktemp -t transferXXX )
    basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9]/-/g')
    curl -vvv --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile;
    cat $tmpfile;
    rm -f $tmpfile;
}

alias transfer=transfer

It will replace all 'strange' chars with a hyphen (-).

@nl5887 commented on GitHub: Try this: ``` transfer() { tmpfile=$( mktemp -t transferXXX ) basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9]/-/g') curl -vvv --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; cat $tmpfile; rm -f $tmpfile; } alias transfer=transfer ``` It will replace all 'strange' chars with a hyphen (-).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dutchcoders/transfer.sh#397