Download file from ftp with curl

I’m able do upload to ftp with but I’m missing something while trying to download.
Probably the place to name where the download file is going to be created.
If I turn verbose to true it says it downloaded (though there’s a Maxdownload = -1 showing up…)
I get (some stuff changed for privacy):

  • Trying…
  • Connected to ( port 21 (#0)
    220---------- Welcome to FTPd [privsep] [TLS] ----------
    220-You are user number 17 of 50 allowed.
    220-Local time is now 17:35. Server port: 21.
    220-This is a private system - No anonymous login
    USER myuser
    331 User myuser OK. Password required
    PASS mypass
    230-OK. Current restricted directory is /
    230 97 Kbytes used (0%) - authorized: 1024000 Kb
    257 “/” is your current location
  • Entry path is ‘/’
    CWD teste
  • ftp_perform ends with SECONDARY: 0
    250 OK. Current directory is /teste
  • Connect data stream passively
    229 Extended Passive mode OK (|||52390|)
  • Trying…
  • Connecting to ( port 52390
  • Connected to ( port 21 (#0)
    TYPE I
    200 TYPE is now 8-bit binary
    SIZE desktop.ini
    213 282
    RETR desktop.ini
    150 Accepted data connection
  • Maxdownload = -1
  • Getting file with size: 282

    [ . S h e l l C l a s s I n f o ]
    L o c a l i z e d R e s o u r c e N a m e = @ % S y s t e m R o o t % \ s y s t e m 3 2 \ s h e l l 3 2 . d l l , 2 1 7 6 9
    I c o n R e s o u r c e = % S y s t e m R o o t % \ s y s t e m 3 2 \ i m a g e r e s . d l l , - 1 8 3
  • Remembering we are in dir “teste/”
    226-File successfully transferred
    226 0.002 seconds (measured here), 154.98 Kbytes per second
  • Connection #0 to host left intact

when I do:

var curl:CURL = new CURL();
curl.setOption(CONNECTTIMEOUT, 30);
curl.setOption(VERBOSE, true);
curl.setOption(URL, “”);
curl.setOption(USERPWD , “myuser:mypass”);

So basically file “desktop.ini” is being “downloaded” to console, I just don’t know where to or how to direct it to some place. Some way I can set that, been going through docs but didn’t find it.

Have you tried setting the WRITEFUNCTION option?

It should call once at the end of the request (due to HXCPP garbage collection issues with more frequent callbacks) unless you use CURLMulti which has the ability to send updates

1 Like

Added just before curl.perform() : curl.setOption(WRITEFUNCTION, testfile);

function testfile(e,f)

That fixed it.
Thanks for pointing out the fix @singmajesty

1 Like