2

I am uploading files to a Confluence API endpoint using a bash script. When I upload file containing special characters in its name such as ä, ö, ü using CURL, they are replaced with '??'. For example, if I upload file with name "Bestätigung.pdf", it is uploaded as "Best??tigung.pdf". However, if I upload the file manually, all is fine, so the encoding problem is on my side.

Below is given the command that I use for the file upload.

fileName="Bestätigung.pdf"
curl -k -v -S -u ${AUTH_CREDENTIALS} -X POST -H "X-Atlassian-Token: nocheck" -H "${API_KEY}" -D "${curlHeaders}" -o "${curlBody}" -F "file=@\"${fileName}\"" -F "comment=Uploaded via API" ${URL}

Can you please give me some suggestions how to keep these special characters in the filename? Thank you!

Victoria
  • 159
  • 2
  • 2
  • 13
  • I think you need to specify UTF-8 in the POST. https://stackoverflow.com/a/708942/7582247 Apparently "_the default encoding of a HTTP POST is ISO-8859-1_. – Ted Lyngmo Mar 15 '21 at 10:41
  • @TedLyngmo The wording in the [HTTP spec](https://tools.ietf.org/html/rfc2616#section-3.7.1) seems to me to suggest the ISO-8859-1 default is only applied to the content of the file, and not to the encoding of the filename itself. I assume that if a charset is specified, that the charset also applies only to the file contents, and not to the filename. – Shane Bishop Mar 15 '21 at 17:04
  • If you are willing to use python, it might be worth taking a look at the answers [here](https://stackoverflow.com/questions/33717690/python-requests-post-with-unicode-filenames). – Shane Bishop Mar 15 '21 at 17:08

0 Answers0