Search code examples
linuxwindowsfilecurlformatting

Curl - File format issue : Linux versus Windows


I have the following .dat file in Linux : U|205003509999|PMBARTICLE2|02000000|02000000|3|PM|F. AJDJDJ|K|00000.0000|K|1|00000002|10999|3500002|||||0|0||00000.0000|150|

It is a flat file composed of a few columns separated by | character.

I am using the following command: curl -X POST https://AAAAA.XXXX.YY/vcloud/v1/stores/tata.toto/items/files/BO-PRIX.dat -H "Content-Type:application/octet-stream" -H "Ocp-Apim-Subscription-Key:c0jdjdjdjdjdjdjzzziz" --data-binary "file.dat"

With the same file and command, in Windows, the command works perfectly. With the same file and command, in Linux, the command works perfectly **BUT **the format of the file received on https side is not expected as it is seen as a file without any columns.

I tried to convert the file with iconv from utf8 to several formats and also to replace --data-binary by --data in the command line but it didn't help.

I need the format of the file to be OK from Linux.


Solution

  • You'll have to use data-binary as --data-binary "@file.dat"

    The @ symbol before file.dat, tells curl to read the file's contents as the data to be uploaded.