FTP Download

Sarah Reichelt sarah.reichelt at gmail.com
Tue Feb 10 17:11:20 EST 2009


> Solved. The socket timeout was the problem, I put a more big value and now
> is running and downloading.
>
> About your code:
> on downloadDone pURL, pURLStatus
>    -- show completion message
>    put "Download complete: " & pURLStatus
> end downloadDone
>
> How pass or obtain the pURLStatus?
> With..
>
> put the urlstatus of "ftp://.." into pURLStatus ?  for example, but where is
> the best handler to put?


If you have a callback for when the download is finished (downloadDone
in my example), then the URL status of the download is automatically
sent to this handler as the second parameter. The URL is the first
parameter so if you are doing multiple downloads, you can check which
one has finished.

If you want more regular feeedback on the status of a download (or
upload), then you can set a status callback. e.g.
   libURLSetStatusCallback "showStatus", fld "Status"
which will send the "showStatus" message to a field called "Status"
periodically during the download.

In the "Status" field script, put something like this:

on showStatus pURL, pStatus
  put pURL & ":" && pStatus into me
end showStatus

This will give you a very basic indication of what is happening. Once
you have worked out the format, you can change this to show a progress
bar, or percentage of the download, or even calculate the speed of
download and expected duration.

When the download is finished, use
   libURLSetStatusCallback
with no parameters, to turn off the status reporting.

HTH,
Sarah



More information about the use-livecode mailing list