YOUSEFUL / FILEMAKER

YsflFtp — function reference

FAQ, examples and tutorial

Function prefix YsflFt_, 20 functions. FTP and FTPS (explicit AUTH TLS or implicit on port 990) over Schannel; passive mode; data connections resume the control connection's TLS session as most FTPS servers require. SFTP (SSH) is not included. Failures return ? message carrying the server reply (? FTP RETR: 550 no such file).

Sessions

YsflFt_Connect logs in and returns a session id that the other functions take as their first parameter. Up to 16 sessions may be open; all are closed when the plugin unloads.

Connect options (space-separated): port=N, tls=none|explicit|implicit, timeout=<sec> (default 30), verify=0 (ignore certificate errors). The server may be host or host:port.

Function Returns
YsflFt_Connect ( server ; user ; password ; {options} ) session id
YsflFt_Disconnect ( session ) 0; * closes every session
YsflFt_List ( session ; {path} ; {options} ) listing lines; option names returns bare names (NLST)
YsflFt_Download ( session ; remote ; local ) 0
YsflFt_Upload ( session ; local ; remote ) 0
YsflFt_DownloadContainer ( session ; remote ) container named after the remote file
YsflFt_UploadContainer ( session ; container ; remote ) 0; empty remote = the container's file name
YsflFt_Delete ( session ; remote ) 0
YsflFt_Rename ( session ; from ; to ) 0 (also moves between directories)
YsflFt_MakeDir ( session ; path ), YsflFt_RemoveDir ( session ; path ) 0
YsflFt_ChangeDir ( session ; path ), YsflFt_CurrentDir ( session ) 0 / current directory
YsflFt_Size ( session ; remote ) bytes
YsflFt_Exists ( session ; remote ) 1 for a file or directory, else 0
YsflFt_Command ( session ; command ) the server's reply text (multi-line replies joined)
YsflFt_Version, YsflFt_Register, YsflFt_LastError, YsflFt_LastErrorText

Paths are as the server sees them; relative paths resolve against the session's current directory. Transfers are binary.

Examples

Example
Set Variable [ $s ; YsflFt_Connect ( "ftp.example.com" ; $user ; $pw ; "tls=explicit" ) ]
If [ Left ( $s ; 1 ) = "?" ]  # connection or login failed
Set Variable [ $r ; YsflFt_ChangeDir ( $s ; "/incoming" ) ]
Set Variable [ $r ; YsflFt_UploadContainer ( $s ; Orders::PDF ; "order-" & Orders::ID & ".pdf" ) ]
Set Variable [ $names ; YsflFt_List ( $s ; "" ; "names" ) ]
Set Field [ Imports::File ; YsflFt_DownloadContainer ( $s ; "prices.csv" ) ]
Set Variable [ $r ; YsflFt_Disconnect ( $s ) ]