Sending files via FTP, FTPS (SSL/TLS)
Contents
Say you have the means of getting the path to an image file in your file system. Here is a sample script for a “To Translator” component, showing how you can use the net api to upload that file to a server via FTP/FTPS/SFTP:
-- The main function is the first function called from Iguana. -- The Data argument will contain the message to be processed. function main(FileId) local FileName = 'Images/'..FileId..'.tiff' local ImageFile = io.open(FileName) if not ImageFile then -- TODO make an email notification rule that sends emails -- whenever a log message starting with -- 'Image file does not exist' is found. print('Image file does not exist: "'..FileName..'".') return else ImageFile:close() end -- set up the connection and send the file local Ftp = net.ftp.init{server='192.168.0.100',username='fred',password='secret'} Ftp:put{local_path=FileName,remote_path='/ScanImages/'..FileId..'.tiff'} end
In this example, I’ve just constructed the path from the ID that gets passed into the main function. This ID is produced from a “From Translator” component (see Polling a database, and generating CSV files). Note the “TODO” comment – you can set up an Iguana email notification rule to send out an email when a specific problem is encountered.
Note: FTPS/SFTP are also supported, see the api documentation for details.
For more information regarding “Details on Server SSL Certificates”, please refer to: http://curl.haxx.se/docs/sslcerts.html