Search code examples
shellcurlmsyssynology

Curl changes multipart/form-data path parameter


I try to send some multipart/form-data data using curl in a msys shell to a NAS named Synology. The form-data needs a parameter named "path" and must formated like "/dir/dir2". The slashes can't be changed.
My problem is, when i am using curl the path variable will be changed to "C:/git-sdk-64/dir/dir2" and i don't know how to prevent it. My command looks like this:

curl -X POST \
  'http://url:port/webapi/entry.cgi?_sid=secret&api=SYNO.FileStation.Upload&method=upload&version=2' \
  -F "path=/dir/dir2" \
  -F 'overwrite=true' \
  -F 'filename=@/c/Temp/test.txt'

Solution

  • Thanks to Daniel Stenberg's info i found out this is a "problem" with msys self. Msys fills up the path variable. Written down here http://www.mingw.org/wiki/Posix_path_conversion. The solution is to put an semicolon at the end of the path. The complete command now looks like this:

    curl -X POST \
      'http://url:port/webapi/entry.cgi?_sid=secret&api=SYNO.FileStation.Upload&method=upload&version=2' \
      -F "path=/dir/dir2;" \
      -F 'overwrite=true' \
      -F 'filename=@/c/Temp/test.txt'