2

I'm trying to download a file in FTPs server by CURL but when I use 2 commands it will give 2 different results. Example: I have the file fileName.zip have size is 40mb.

When I use the first command:

curl --insecure -u username:password ftps://host:port//download/folder1/fileName.zip --output fileNameDownload.zip

It will return for me the file fileNameDownload.zip with size 40MB, this file is OK.

And I try another way to download this file with the command:

curl --insecure -u username:password ftps://host:port -X "RETR download/folder1/fileName.zip" --output fileNameDownload.zip

It will return for me the file fileNameDownload.zip with size 40.2MB and I cannot open this file.

How to make the second command correct?

Ngọc Tú
  • 21
  • 4
  • Do you have looked into the second file with a text editor? I assume that it contains header information at it's start. – PowerStat Oct 05 '18 at 09:04
  • I'm already trying to test it again with textFIle.txt file and the second command working OK, but when I zip the textFile.txt to textFIle.zip and download again with the second command it will return the testFile.zip but I cannot unzip this file – Ngọc Tú Oct 05 '18 at 09:53
  • And when I open 2 zip file with a text editor and copy the content to https://www.diffchecker.com/diff and it said "The two files are identical" but the 1st command gave me a file with size 701byte and 2nd command gave me a file with size 704byte – Ngọc Tú Oct 05 '18 at 10:02
  • 1
    ![Different from two file](https://cdn1.imggmi.com/uploads/2018/10/5/8a9e20080f7a518437d6730f5f340989-full.png). I found the different from two file – Ngọc Tú Oct 05 '18 at 10:17
  • Are you using the latest curl version? On which platform? If not please try them - if so I think it's worth opening a bug report: https://curl.haxx.se/docs/bugs.html – PowerStat Oct 05 '18 at 10:36
  • I found the problem because I used -X option and CURL have a script for this in the script have stepped to set TYPE = A. (In the 1st command CURL set TYPE = I;) A TYPE request controls the binary flag. It has a parameter. There are four possibilities for the parameter: A: Turn the binary flag off. A N: Turn the binary flag off. I: Turn the binary flag on. L 8: Turn the binary flag on. That is the reason why I download file with wrong content. – Ngọc Tú Oct 05 '18 at 11:51
  • Cool, so you could write your own answer here now ;-) – PowerStat Oct 05 '18 at 11:58

1 Answers1

0

I found the problem because I used -X option and CURL have a script for this. In the script have stepped to set TYPE = A. (In the 1st command CURL set TYPE = I)

A TYPE request controls the binary flag. It has a parameter. There are four possibilities for the parameter:

A: Turn the binary flag off.

A N: Turn the binary flag off.

I: Turn the binary flag on.

L 8: Turn the binary flag on.

That is the reason why I download file with wrong content

Ngọc Tú
  • 21
  • 4