0

Per our IT department, I have to use a curl command to upload files to our SFTP server.

I use a Jenkins pipeline to build our artifacts on Windows build nodes, which are *.zip files, and this is the curl command I use

C:\> curl -V
curl 7.03.1 (Windows) libcurl/7.03.1 Schannel

C:> curl -T ./build_artifact.zip -u 'user:password' ftp://ftp.company.com/devops/test/build_artifact.zip --ftp-ssl-reqd --ftp-create-dirs -k

The file uploads correctly.

But when I download the file on my Mac and I unzip it, I get

$ unzip build_artifact.zip
Archive:  build_artifact.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of build_artifact.zip or
        build_artifact.zip.zip, and cannot find build_artifact.zip.ZIP, period.

Note if I execute the same curl command on my Mac to upload to the SFTP site, I can readily unzip the artifact when I subsequently download it.

Any clues on why this happens, and how to fix it?

djmonki
  • 131
  • 5
Chris F
  • 477
  • 1
  • 4
  • 17

2 Answers2

1

This could be the common known issue based on the upload transfer of binary files using the curl command on Windows.

By default, curl on a Windows device uses ASCII transfer mode which can cause issues with binary files like .zip archives. Whereas on a Mac device, the curl command uses binary transfer mode as default.

To avoid this, override the ASCII transfer method by implicitly specifying the transfer mode as binary, by using the --ftp-binary option.

See amended command below:

$ curl -T ./build_artifact.zip -u 'user:password' ftp://ftp.company.com/devops/test/build_artifact.zip --ftp-ssl-reqd --ftp-create-dirs -k --ftp-binary

djmonki
  • 131
  • 5
-1

Updating to the latest Git bash, which included curl v8.x fixed the issue.

Chris F
  • 477
  • 1
  • 4
  • 17