Downloading from an FTP server is done by a Task asynchronously (other Tasks will be executed concurrently without blocking execution flow)
Ftp:download(filename, [local_filename]) method
Download a remote file from the FTP server, to the current local directory.
Parameters
filename
A string that contains the name of the file to be retrieved from the FTP server.
[local_filename]
An optional string
that contains the name of the file in the current local directory. If not provided, the remote filename will be used.
Return value
This method return a Task instance. Once the Task has finished, it will return one of the following possible values :
- File value representing the downloaded file. If the file already exists in the current directory, it will be overwritten.
false
value if the operation failed. You can get more information with the net.error property.
Example
local net = require "net"
-- connect to official ftp Ubuntu server
local client = net.Ftp("ftp://ftp.ubuntu.com", "anonymous", "guest")
-- download file "favicon.ico" to the current directory
if await(client:download("/releases/favicon.ico")) then
print("Successfully downloaded 'favicon.ico' from ftp://ftp.ubuntu.com")
else
print(client.log)
end