360Works FTPeek/Documentation

From 360Works Product Documentation Wiki
(Difference between revisions)
Jump to: navigation, search
m (Auto-upload documentation)
m (Auto-upload documentation)
 
(3 intermediate revisions by one user not shown)
Line 60: Line 60:
 
=Function Summary=
 
=Function Summary=
 
<div id="toc">
 
<div id="toc">
*[[#FTPeek_ChangeDir|FTPeek_ChangeDir]] ( remoteDir ) &mdash; Changes the working directory to a specified directory.
 
*[[#FTPeek_ChangeDirRoot|FTPeek_ChangeDirRoot]] (  ) &mdash; Changes the working directory to the root directory of the server.
 
*[[#FTPeek_ChangeDirUp|FTPeek_ChangeDirUp]] (  ) &mdash; Changes the working directory to the parent of the current directory.
 
 
*[[#FTPeek_ChooseFile|FTPeek_ChooseFile]] ( { initialPath ; fileType ; title } ) &mdash; Pops up a file chooser dialog.
 
*[[#FTPeek_ChooseFile|FTPeek_ChooseFile]] ( { initialPath ; fileType ; title } ) &mdash; Pops up a file chooser dialog.
*[[#FTPeek_ConnectFTP|FTPeek_ConnectFTP]] ( host ; username ; password { ; flag1 ; flag2 ; ... } ) &mdash; Connects to an FTP (File Transfer Protocol) server with the specified address, username, and password.
 
*[[#FTPeek_ConnectFTPS|FTPeek_ConnectFTPS]] ( host ; username ; password { ; flag1 ; flag2 ; ... } ) &mdash; Connect to a FTPS (File Transfer Protocol over SSL) server.
 
*[[#FTPeek_ConnectSFTP|FTPeek_ConnectSFTP]] ( host ; publicKey ; username ; password { ; flag1 ; flag2 ; ... }  ) &mdash; Connects to an SFTP (SSH File Transfer Protocol) server with the specified address, public key, username, and
 
password.
 
*[[#FTPeek_DeleteDir|FTPeek_DeleteDir]] ( remoteDir { ; recursiveFlag } ) &mdash; Deletes the specified empty remote directory.
 
*[[#FTPeek_DeleteFile|FTPeek_DeleteFile]] ( remoteFile { ; wildcardFlag } ) &mdash; Deletes the specified remote file.
 
*[[#FTPeek_DeleteLocal|FTPeek_DeleteLocal]] ( localFile ) &mdash; Deletes the specified local file.
 
*[[#FTPeek_Disconnect|FTPeek_Disconnect]] (  ) &mdash; Disconnects from the server and quits the current SFTP/FTP/FTPS session.
 
*[[#FTPeek_DownloadFile|FTPeek_DownloadFile]] ( remoteSourcePath ; localDestPath { ; newLocalFileName } ) &mdash; Downloads a file to the specified directory and optionally renames the file.
 
 
*[[#FTPeek_DownloadFileToContainer|FTPeek_DownloadFileToContainer]] ( remoteSourcePath ) &mdash; Downloads a file and returns file's data into a container field, sets transfer type for this action to Binary unless specified otherwise in <code>FTPeek_SetTransferType( type )</code>.
 
*[[#FTPeek_DownloadFileToContainer|FTPeek_DownloadFileToContainer]] ( remoteSourcePath ) &mdash; Downloads a file and returns file's data into a container field, sets transfer type for this action to Binary unless specified otherwise in <code>FTPeek_SetTransferType( type )</code>.
 
*[[#FTPeek_DownloadFileToField|FTPeek_DownloadFileToField]] ( remoteSourcePath { ; encoding } ) &mdash; Downloads a file and returns file's data as text.
 
*[[#FTPeek_DownloadFileToField|FTPeek_DownloadFileToField]] ( remoteSourcePath { ; encoding } ) &mdash; Downloads a file and returns file's data as text.
Line 81: Line 69:
 
*[[#FTPeek_GetPublicKey|FTPeek_GetPublicKey]] ( host ) &mdash; Gets an SFTP server's public key, which must be provided as a parameter to {@link #FTPeek_ConnectSFTP}.
 
*[[#FTPeek_GetPublicKey|FTPeek_GetPublicKey]] ( host ) &mdash; Gets an SFTP server's public key, which must be provided as a parameter to {@link #FTPeek_ConnectSFTP}.
 
*[[#FTPeek_IsConnected|FTPeek_IsConnected]] (  ) &mdash; Returns connection status.
 
*[[#FTPeek_IsConnected|FTPeek_IsConnected]] (  ) &mdash; Returns connection status.
*[[#FTPeek_LastError|FTPeek_LastError]] &mdash; Returns detailed information about the last error generated by this plugin.
+
*[[#FTPeek_LastError|FTPeek_LastError]] (  ) &mdash; Returns detailed information about the last error generated by this plugin.
*[[#FTPeek_LicenseInfo|FTPeek_LicenseInfo]] &mdash; Returns license information about the plugin.
+
*[[#FTPeek_LastErrorCode|FTPeek_LastErrorCode]] (  ) &mdash; Returns the FTP reply code from the most recent FTP command that resulted in error.
*[[#FTPeek_MakeDir|FTPeek_MakeDir]] ( remoteDir ) &mdash; Creates a remote directory or directory path.
+
*[[#FTPeek_LicenseInfo|FTPeek_LicenseInfo]] ( ) &mdash; Returns license information about the plugin.
*[[#FTPeek_Register|FTPeek_Register]] ( licenseKey ; registeredTo ) &mdash; Registers the plugin.
+
*[[#FTPeek_Rename|FTPeek_Rename]] ( from ; to ) &mdash; Renames a file on the remote server.
+
 
*[[#FTPeek_ScanLocalDir|FTPeek_ScanLocalDir]] ( localPath ; recursive ) &mdash; Do not use this function - it is only included for backwards compatibility and will be removed from a future version of FTPeek.
 
*[[#FTPeek_ScanLocalDir|FTPeek_ScanLocalDir]] ( localPath ; recursive ) &mdash; Do not use this function - it is only included for backwards compatibility and will be removed from a future version of FTPeek.
 
*[[#FTPeek_ScanLocalDirectory|FTPeek_ScanLocalDirectory]] ( localPath ; isPathFromFileMaker ) &mdash; Scans a local directory and returns a return-separated list of files in the directory.
 
*[[#FTPeek_ScanLocalDirectory|FTPeek_ScanLocalDirectory]] ( localPath ; isPathFromFileMaker ) &mdash; Scans a local directory and returns a return-separated list of files in the directory.
*[[#FTPeek_SetErrorCapture|FTPeek_SetErrorCapture]] ( errorCapture ) &mdash; Toggles error dialogs on or off.
+
*[[#FTPeek_Version|FTPeek_Version]] ( ) &mdash; Returns the version number of the plugin.
*[[#FTPeek_SetShowProgress|FTPeek_SetShowProgress]] ( showProgressFlag ) &mdash; Configures whether to show progress bars on upload/download.
+
*[[#FTPeek_SetTransferType|FTPeek_SetTransferType]] ( type ) &mdash; Explicitly sets the transfer mode for uploading and downloading.
+
*[[#FTPeek_UploadFile|FTPeek_UploadFile]] ( remoteDestPath ; localSourcePath ) &mdash; Uploads a file to the remote server.
+
*[[#FTPeek_UploadFileFromContainer|FTPeek_UploadFileFromContainer]] ( remoteDestPath ; containerToUpload ) &mdash; Uploads container data as a file to the remote server, sets transfer type for this action to Binary unless specified otherwise in <code>FTPeek_SetTransferType( type )</code>.
+
*[[#FTPeek_UploadFileFromField|FTPeek_UploadFileFromField]] ( remoteDestPath ; textFieldToUpload { ; encoding } ) &mdash; Uploads data from a non-container field as a file to the remote server.
+
*[[#FTPeek_Version|FTPeek_Version]] &mdash; Returns the version number of the plugin.
+
 
</div>
 
</div>
 
=Function Detail=
 
=Function Detail=
<div id="FTPeek_ChangeDir"></div>
 
==FTPeek_ChangeDir ( remoteDir ) ==
 
Changes the working directory to a specified directory. The remoteDir path can be [[#rel_path|relative or absolute]].
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>remoteDir</code> <dd>the directory to navigate into
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_ChangeDirRoot"></div>
 
==FTPeek_ChangeDirRoot (  ) ==
 
Changes the working directory to the root directory of the server.
 
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_ChangeDirUp"></div>
 
==FTPeek_ChangeDirUp (  ) ==
 
Changes the working directory to the parent of the current directory.
 
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
 
<div id="FTPeek_ChooseFile"></div>
 
<div id="FTPeek_ChooseFile"></div>
 
==FTPeek_ChooseFile ( { initialPath ; fileType ; title } ) ==
 
==FTPeek_ChooseFile ( { initialPath ; fileType ; title } ) ==
Line 133: Line 89:
 
  *Note that although all parameters in this function are optional, they are also positional.  This means that if you want to specify a <code>fileType</code> without specifying <code>initialPath</code> you'll need
 
  *Note that although all parameters in this function are optional, they are also positional.  This means that if you want to specify a <code>fileType</code> without specifying <code>initialPath</code> you'll need
 
  pass in an empty string <code>""</code> for the <code>initialPath</code> parameter.
 
  pass in an empty string <code>""</code> for the <code>initialPath</code> parameter.
</div>
 
 
<div id="FTPeek_ConnectFTP"></div>
 
==FTPeek_ConnectFTP ( host ; username ; password { ; flag1 ; flag2 ; ... } ) ==
 
Connects to an FTP (File Transfer Protocol) server with the specified address, username, and password. You
 
must call one of the connect methods ([[#FTPeek_ConnectFTP|FTPeek_ConnectFTP]], [[#FTPeek_ConnectSFTP|FTPeek_ConnectSFTP]], or [[#FTPeek_ConnectFTPS|FTPeek_ConnectFTPS]]) before you can call any other FTP functions.
 
If multiple connect functions are called, the last connection remains as the active working connection. While previous connections will
 
time-out and eventually disconnect, a server may allow a limited number of concurrent connections per account, limiting
 
new connections until the old ones are closed. It is therefore highly recommended to close any active connection before
 
opening a new one.
 
All connections are made in <i>passive mode</i>, unless the optional flag is used to explicitly change the mode to <i>active</i>.
 
 
 
<h3>Active mode</h3>
 
Use the optional arguments to connect to an FTP server using Active instead of the default Passive mode <code>"ActiveMode=true"</code>.
 
<h3>Control channel encoding</h3>
 
Use the optional arguments to connect use a specific encoding for the control channel, <code>"encoding=UTF8>/code>.
 
 
 
Set Variable[$result =
 
    FTPeek_ConnectFTPS(
 
        "ftp.mysite.com" ;
 
        "username" ;
 
        "password" ;
 
        '''"ActiveMode=true" ;'''
 
        '''"encoding=UTF8"'''
 
    )
 
]
 
 
 
 
<h3>Logging level</h3>
 
<ul>
 
<li><strong>DEBUG</strong> - use this logging level to produce detail log of ftp operations</li>
 
</ul>
 
 
Set Variable[$result =
 
    FTPeek_ConnectFTPS(
 
        "ftp.mysite.com" ;
 
        "username" ;
 
        "password" ;
 
        '''"LoggingLevel=DEBUG"'''
 
    )
 
]
 
 
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>host</code> <dd>address of the server; can be numeric IP address like <code>"127.0.0.1"</code> or a named one like <code>"ftp.mysite.com"</code>; if need to connect to a non-standard port number, concatenate the port number to the host name like <code>"ftp.mysite.com:21"</code>.
 
<dt><code>username</code> <dd>the client username.
 
<dt><code>password</code> <dd>the client authentication password.
 
<dt><code>args</code> <dd>Additional optional arguments <code>ActiveMode</code>, <code>encoding</code>.
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_ConnectFTPS"></div>
 
==FTPeek_ConnectFTPS ( host ; username ; password { ; flag1 ; flag2 ; ... } ) ==
 
Connect to a FTPS (File Transfer Protocol over SSL) server. You
 
must call one of the connect methods ([[#FTPeek_ConnectFTP|FTPeek_ConnectFTP]], [[#FTPeek_ConnectSFTP|FTPeek_ConnectSFTP]], or [[#FTPeek_ConnectFTPS|FTPeek_ConnectFTPS]]) before you can call any other FTP functions.<br>If multiple
 
connect functions are called, the last connection remains as the active working connection. While previous connections will
 
time-out and eventually disconnect, a server may allow a limited number of concurrent connections per account, limiting
 
new connections until the old ones are closed. It is therefore highly recommended to call [[#FTPeek_Disconnect|FTPeek_Disconnect]] to close any active connection before
 
opening a new one.
 
 
Here is an example of connecting to FTPS server:
 
 
Set Variable[$result =
 
    FTPeek_ConnectFTPS(
 
        "ftp.mysite.com" ;
 
        "username" ;
 
        "password"
 
    )
 
]
 
 
 
 
<h3>No server certificate validation</h3>
 
Use the optional arguments to disable server certificate validation by passing <code>"ValidateServerCertificate=false"</code>.
 
 
Set Variable[$result =
 
    FTPeek_ConnectFTPS(
 
        "ftp.mysite.com" ;
 
        "username" ;
 
        "password" ;
 
        '''"ValidateServerCertificate=false"'''
 
    )
 
]
 
 
 
 
<h3>FTPS implicit</h3>
 
Use the optional arguments to use implicit FTPS mode <code>"ImplicitFTPS=true"</code>.
 
 
Set Variable[$result =
 
    FTPeek_ConnectFTPS(
 
        "ftp.mysite.com" ;
 
        "username" ;
 
        "password" ;
 
        '''"ImplicitFTPS=true"'''
 
    )
 
]
 
 
 
 
<h3>Start With Clear Data Channels</h3>
 
Use the optional arguments to start with clear data channels.
 
Use this if the connect function returns a "USER and PASS required first" error. <code>"StartWithClearDataChannels=true"</code>.
 
 
Set Variable[$result =
 
    FTPeek_ConnectFTPS(
 
        "ftp.mysite.com" ;
 
        "username" ;
 
        "password" ;
 
        '''"StartWithClearDataChannels=true"'''
 
    )
 
]
 
 
 
 
<h3>Active mode </h3>
 
Use the optional arguments to connect to an FTP server using Active instead of the default Passive mode <code>"ActiveMode=true"</code>.
 
<h3>Control channel encoding</h3>
 
Use the optional arguments to connect use a specific encoding for the control channel, <code>"encoding=UTF8>/code>.
 
 
 
Set Variable[$result =
 
    FTPeek_ConnectFTPS(
 
        "ftp.mysite.com" ;
 
        "username" ;
 
        "password" ;
 
        '''"ActiveMode=true" ;'''
 
        '''"encoding=UTF8"'''
 
    )
 
]
 
 
 
 
<h3>SSL flags</h3>
 
<ul>
 
<li><strong>DisableDataSslClosure</strong> - use if plugin hangs after a file transfer completes, this happens when FTPS server does not send the data chanel ssl closure response</li>
 
<li><strong>DisableControlWaitOnClose</strong> - use if plugin hangs after a file transfer completes, this happens when FTPS server does not send the control chanel ssl closure response</li>
 
<li><strong>DisableSslClosure</strong> - use if plugin returns a premature SSL closure error</li>
 
</ul>
 
 
Set Variable[$result =
 
    FTPeek_ConnectFTPS(
 
        "ftp.mysite.com" ;
 
        "username" ;
 
        "password" ;
 
        '''"DisableDataSslClosure=true" ;'''
 
        '''"DisableSslClosure=true"'''
 
    )
 
]
 
 
 
 
 
<h3>Logging level</h3>
 
<ul>
 
<li><strong>DEBUG</strong> - use this logging level to produce detail log of ftp operations</li>
 
</ul>
 
 
Set Variable[$result =
 
    FTPeek_ConnectFTPS(
 
        "ftp.mysite.com" ;
 
        "username" ;
 
        "password" ;
 
        '''"LoggingLevel=DEBUG"'''
 
    )
 
]
 
 
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>host</code> <dd>address of the server; can be numeric IP address like <code>"127.0.0.1"</code> or a named one like <code>"ftp.mysite.com"</code>; if need to connect to a non-standard port number, concatenate  the port number to the host name like <code>"ftp.mysite.com:990"</code>
 
<dt><code>username</code> <dd>the client username
 
<dt><code>password</code> <dd>the client authentication password
 
<dt><code>args</code> <dd>Additional optional arguments (<code>ValidateServerCertificate, ImplicitFTPS, ActiveMode, encoding, ssl flags, logging level (see examples)</code>).
 
</dl></div>
 
<div class="see"><strong>See also:</strong>  [[#FTPeek_Disconnect|FTPeek_Disconnect]]
 
</div><div class="see"><strong>Returns:</strong> 1 on successful connection, or "ERROR" if an error occurred (use FTPeek_LastError in this case)
 
</div>
 
 
<div id="FTPeek_ConnectSFTP"></div>
 
==FTPeek_ConnectSFTP ( host ; publicKey ; username ; password { ; flag1 ; flag2 ; ... }  ) ==
 
Connects to an SFTP (SSH File Transfer Protocol) server with the specified address, public key, username, and
 
password. You must call one of the connect methods ([[#FTPeek_ConnectFTP|FTPeek_ConnectFTP]], [[#FTPeek_ConnectSFTP|FTPeek_ConnectSFTP]], or [[#FTPeek_ConnectFTPS|FTPeek_ConnectFTPS]]) before you can call any other FTP
 
functions.<br>If multiple connect functions are called, the last connection remains as the active working connection. While previous connections will
 
time-out and eventually disconnect, a server may allow a limited number of concurrent connections per account, limiting
 
new connections until the old ones are closed. It is therefore highly recommended to close any active connection before
 
opening a new one.
 
 
 
<h3>Logging level</h3>
 
<ul>
 
<li><strong>DEBUG</strong> - use this logging level to produce detail log of ftp operations</li>
 
</ul>
 
 
Set Variable[$result =
 
    FTPeek_ConnectSFTP(
 
        "ftp.mysite.com" ;
 
        "####Public Key####" ;
 
        "username" ;
 
        "password" ;
 
        '''"LoggingLevel=DEBUG"'''
 
    )
 
]
 
 
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>host</code> <dd>address of the server; can be numeric IP address like <code>"127.0.0.1"</code> or a named one like <code>"ftp.mysite.com"</code>; if need to connect to a non-standard port number, concatenate the port number to the host name like <code>"ftp.mysite.com:21"</code>
 
<dt><code>publicKey</code> <dd>the unique key of the server, obtained by calling {@link #FTPeek_GetPublicKey}. If a wrong key is entered, the connection will be refused and this error thrown: "The host signature is invalid or the host key was not accepted!"
 
<dt><code>username</code> <dd>the client username
 
<dt><code>password</code> <dd>the client authentication password
 
<dt><code>args</code> <dd>Additional optional arguments <code>LoggingLevel</code>.
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_DeleteDir"></div>
 
==FTPeek_DeleteDir ( remoteDir { ; recursiveFlag } ) ==
 
Deletes the specified empty remote directory. Trying to delete a non-empty remote directory will produce an error, unless recursive delete flag is specified.
 
The remoteDir path can be [[#rel_path|relative or absolute]].
 
Here is an example:
 
 
Set Variable [ $deleteDir ; FTPeek_DeleteDir( "Empty/Directory" ) //relative path example ]
 
Set Variable [ $deleteDir ; FTPeek_DeleteDir( "/home/files/Non empty directory" ; "recursive=true" ) //absolute path example]
 
 
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>remoteDir</code> <dd>remote directory to delete
 
<dt><code>recursiveFlag</code> <dd>optional parameter, specify <code>recursive=true</code> to enable recursive delete
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_DeleteFile"></div>
 
==FTPeek_DeleteFile ( remoteFile { ; wildcardFlag } ) ==
 
Deletes the specified remote file.
 
The remoteFile path can be [[#rel_path|relative or absolute]].
 
Here is an example:
 
 
Set Variable [ $deleteFile ; FTPeek_DeleteFile( "remoteFiles.txt" ) ]
 
Set Variable [ $deleteFiles ; FTPeek_DeleteFile( "remoteFiles.*" ; "wildcards=true" ) ]
 
 
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>remoteFile</code> <dd>remote file path to delete
 
<dt><code>useWildcards</code> <dd>optional parameter, specify <code>wildcards=true</code> to enable wildcard characters <code>*</code> and <code>?</code> in the remote file name to delete matching files.
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_DeleteLocal"></div>
 
==FTPeek_DeleteLocal ( localFile ) ==
 
Deletes the specified local file.  If deleting a folder/directory, it must first be emptied.
 
<pre>
 
Set Variable [ $deleteLocal ; FTPeek_DeleteLocal( "/Users/username/Desktop/upload.gif" ) ]
 
Set Variable [ $deleteLocal ; FTPeek_DeleteLocal( "c:\\Documents and Settings\\username\\Desktop\\upload.txt" ) ]
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>localFile</code> <dd>file on the local file system.
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure.
 
</div>
 
 
<div id="FTPeek_Disconnect"></div>
 
==FTPeek_Disconnect (  ) ==
 
Disconnects from the server and quits the current SFTP/FTP/FTPS session.
 
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_DownloadFile"></div>
 
==FTPeek_DownloadFile ( remoteSourcePath ; localDestPath { ; newLocalFileName } ) ==
 
Downloads a file to the specified directory and optionally renames the file.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>remoteSourcePath</code> <dd>the file path on the remote FTP server to download
 
<dt><code>localDestPath</code> <dd>the directory on the computer running FileMaker Pro where the downloaded file should be stored, for example <code>"/Users/Shared/Downloads/"</code> or <code>"filemac:/Macintosh HD/Users/Shared/Downloads/"</code>
 
<dt><code>newLocalFileName</code> <dd>an optional parameter that can be used to locally rename the downloaded file. If left empty, the file will be named whatever it was named on the FTP server.
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
 
</div>
 
</div>
  
Line 512: Line 181:
  
 
<div id="FTPeek_LastError"></div>
 
<div id="FTPeek_LastError"></div>
==FTPeek_LastError==
+
==FTPeek_LastError (  ) ==
 
Returns detailed information about the last error generated by this plugin. If another plugin function returns the
 
Returns detailed information about the last error generated by this plugin. If another plugin function returns the
 
text <code>"ERROR"</code>, call this function to get a user-presentable description of what went wrong. For example,
 
text <code>"ERROR"</code>, call this function to get a user-presentable description of what went wrong. For example,
Line 523: Line 192:
  
 
<div class="see"><strong>Returns:</strong> Error text, or <code>null</code> if there was no error.
 
<div class="see"><strong>Returns:</strong> Error text, or <code>null</code> if there was no error.
 +
</div>
 +
 +
<div id="FTPeek_LastErrorCode"></div>
 +
==FTPeek_LastErrorCode (  ) ==
 +
Returns the FTP reply code from the most recent FTP command that resulted in error.
 +
 +
<div class="see"><strong>Returns:</strong> An integer if an error occurred.
 
</div>
 
</div>
  
 
<div id="FTPeek_LicenseInfo"></div>
 
<div id="FTPeek_LicenseInfo"></div>
==FTPeek_LicenseInfo==
+
==FTPeek_LicenseInfo (  ) ==
 
Returns license information about the plugin. This shows whether it is registered, and what type of license is being used.
 
Returns license information about the plugin. This shows whether it is registered, and what type of license is being used.
  
 
<div class="see"><strong>Returns:</strong> plugin license information
 
<div class="see"><strong>Returns:</strong> plugin license information
</div>
 
 
<div id="FTPeek_MakeDir"></div>
 
==FTPeek_MakeDir ( remoteDir ) ==
 
Creates a remote directory or directory path. If there are multiple directories in the path hierarchy that do not exist, all of them are created as necessary.  Only ASCII characters are supported for directory names.
 
The remoteDir path can be [[#rel_path|relative or absolute]].
 
Here is an example:
 
 
Set Variable [ $result ; FTPeek_MakeDir( "New Folder" ) //relative path example ]
 
Set Variable [ $result ; FTPeek_MakeDir( "/home/files/newDir" ) //absolute path example]
 
 
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>remoteDir</code> <dd>remote directory path to create
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_Register"></div>
 
==FTPeek_Register ( licenseKey ; registeredTo ) ==
 
Registers the plugin. This will not be retained at the next launch of FileMaker, so if you're using this method to register
 
the plugin, you'll want to call this in the startup script. For developer licenses, this is the only way to register the plugin.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>licenseKey</code> <dd>registration key
 
<dt><code>registeredTo</code> <dd>register to entity
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_Rename"></div>
 
==FTPeek_Rename ( from ; to ) ==
 
Renames a file on the remote server. The from and to paths can be [[#rel_path|relative or absolute]], however, the "to" file path must be in the same
 
directory as the "from" file path.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>from</code> <dd>old file name to rename from
 
<dt><code>to</code> <dd>new file name to rename to
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
 
</div>
 
</div>
  
Line 626: Line 261:
 
</dl></div>
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> return-separated list of files in the specified directory
 
<div class="see"><strong>Returns:</strong> return-separated list of files in the specified directory
</div>
 
 
<div id="FTPeek_SetErrorCapture"></div>
 
==FTPeek_SetErrorCapture ( errorCapture ) ==
 
Toggles error dialogs on or off. When something unexpected happens, the plug-in will pop up a dialog displaying the error message. This makes it easy to see what went wrong. However, in some cases, you (the developer) may prefer to show your own message to the user, or possibly not show a message at all. In that case, you can call FTPeek_SetErrorCapture with a parameter of true. That will suppress the error dialog from appearing to the user.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>errorCapture</code> <dd>set to true to suppress the default popups.
 
</dl></div>
 
 
 
<div id="FTPeek_SetShowProgress"></div>
 
==FTPeek_SetShowProgress ( showProgressFlag ) ==
 
Configures whether to show progress bars on upload/download. Once this is set, it remains on that setting until changed, or until FileMaker is quit and restarted.
 
Dialogs are displayed by default.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>showProgressFlag</code> <dd>0 to suppress progress bars, 1 to show progress bars.
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> This always returns a 1.
 
</div>
 
 
<div id="FTPeek_SetTransferType"></div>
 
==FTPeek_SetTransferType ( type ) ==
 
Explicitly sets the transfer mode for uploading and downloading. This overwrites assumptions that FTPeek makes about what kind of file is being uploaded, and allows
 
manual setting of the transfer type to use for an upload or download. Once set, the setting is persistent until changed again.
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>type</code> <dd>Set to <code>"ASCII"</code> to transfer plain text data and files; set to <code>"BINARY"</code> for all non plain text data and files; set to <code>"DEFAULT"</code> to have FTPeek resume making automatic implicit decisions on the transfer type.
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_UploadFile"></div>
 
==FTPeek_UploadFile ( remoteDestPath ; localSourcePath ) ==
 
Uploads a file to the remote server. If the upload directory structure does not exist on the remote server, it will
 
be created as necessary. If the remote destination path is blank the file will be saved in the current working directory. If the
 
remote file name is not specified ( remoteDestPath ends with a '/' slash character ), the remote file will be named the same as
 
the local file.  Only ASCII characters are supported for file names. The remoteDestPath path can be [[#rel_path|relative or absolute]].
 
Please see the note on relative and absolute paths at the top of the page for more information.
 
localSourcePath can be a system specific file path or a URL. ( ex. http://serverAddress/sample.mov ).
 
Here is an example of how to upload a file into the current working directory on the FTP server, retaining the same name as the source file:
 
 
If[ FTPeek_UploadFile( "", "/Library/Desktop Pictures/Lines Blue.jpg" ) = "ERROR" ]
 
Show Custom Dialog[ "Could not upload file"; FTPeek_LastError ]
 
End If
 
 
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>remoteDestPath</code> <dd>remote file or dir path to upload to; will be created if directory structure does not exist; if empty current working directory will be used
 
<dt><code>localSourcePath</code> <dd>local file path to upload
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_UploadFileFromContainer"></div>
 
==FTPeek_UploadFileFromContainer ( remoteDestPath ; containerToUpload ) ==
 
Uploads container data as a file to the remote server, sets transfer type for this action to Binary unless specified otherwise in <code>FTPeek_SetTransferType( type )</code>. If the directory structure to upload to does not exist on the
 
remote server, it will be created as necessary. If the remote file name is not specified ( remoteDestPath ends with a '/' slash character ),
 
the remote file will be named the same as the local file.  Only ASCII characters are supported for file names. The remoteDestPath path can be [[#rel_path|relative or absolute]].
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>remoteDestPath</code> <dd>remote file or dir path to upload to; will be created if directory structure does not exist
 
<dt><code>containerToUpload</code> <dd>container data to upload
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
</div>
 
 
<div id="FTPeek_UploadFileFromField"></div>
 
==FTPeek_UploadFileFromField ( remoteDestPath ; textFieldToUpload { ; encoding } ) ==
 
Uploads data from a non-container field as a file to the remote server. If the destination directory structure does not exist on the
 
remote server, it will be created as necessary. If the remote file name is not specified ( remoteDestPath ends with a '/' slash character ),
 
the remote file will be named <code>Untitled.txt</code>.  Only ASCII characters are supported for file names.  The remoteDestPath path can be [[#rel_path|relative or absolute]].
 
*Note that the default ftp transfer type is BINARY
 
 
<div class="parameters"><strong>Parameters:</strong>
 
<dl><dt><code>remoteDestPath</code> <dd>remote file or dir path to upload to; will be created if directory structure does not exist, will use current directory if empty.
 
<dt><code>textFieldToUpload</code> <dd>text data to upload
 
<dt><code>encoding</code> <dd>optional text encoding.  Some of the supported encodings are <code>"ASCII", "ISO8859_1", "UTF8", "UTF-16"</code>, for more supported encodings consult <a href="http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html">Java supported encodings</a> use the second column of the table as the encoding name.
 
</dl></div>
 
<div class="see"><strong>Returns:</strong> 1 on success, ERROR on failure
 
 
</div>
 
</div>
  
 
<div id="FTPeek_Version"></div>
 
<div id="FTPeek_Version"></div>
==FTPeek_Version==
+
==FTPeek_Version (  ) ==
 
Returns the version number of the plugin. This is always a numeric value, with no letter characters.
 
Returns the version number of the plugin. This is always a numeric value, with no letter characters.
  
 
<div class="see"><strong>Returns:</strong> the version number of the plugin
 
<div class="see"><strong>Returns:</strong> the version number of the plugin
 
</div>
 
</div>

Latest revision as of 03:51, 7 June 2017

Contents

[edit] 360Works FTPeek User Guide

The 360Works FTPeek plugin enables SFTP (encrypted with SSH) / FTP / FTPS (encrypted with SSL) functionality in FileMaker, including:

  • Establish an FTP connection to a server
  • View a list of files in a specified directory
  • Download files from the server to a specified directory
  • Optionally rename the local file upon download

You can select what type of FTP protocol you want to use by using one of the FTPeek_Connect methods. For regular unencrypted FTP, use FTPeek_ConnectFTP. You can also do SFTP with FTPeek_ConnectSFTP or FTPS with FTPeek_ConnectFTPS.</p>

Once you're connected, the plugin functions to upload, download, etc. are the same for all three protocols.</p>

More information about the FTP protocol, as well as the secure variations (SFTP and FTPS) can be found at this <a href="http://en.wikipedia.org/wiki/File_Transfer_Protocol" target="_new">Wikipedia article</a>.

Example Usage

This shows an example of connecting to a secure SFTP server, getting a list of files, and downloading one of them.</p>


Step #1: Get public key of the server. This returns text that can be stored in FileMaker.</p>

Set Field[ example::publicKey; FTPeek_GetPublicKey( "host.address.com" ) ]
If[ example::publicKey = "ERROR" ] ...show error using FTPeek_LastError...

Step #2: Connect to the server. Requires public key and client authentication.</p>

if[ FTPeek_ConnectSFTP( "host.address.com" ; example::publicKey ; "username" ; 
"password" ) = "ERROR" ] ...Handle error...

Step #3: Get a list of files in a directory on the server</p>

Set Field[ example::filesList; FTPeek_GetFileList( "/Users/username/" ) ]
if[ example::filesList = "ERROR" ] ...show error using FTPeek_LastError...

Step #4: Download the first file in the list to a temp directory and name it newFileName.</p>

If[ FTPeek_DownloadFile( "/tmp/" ; GetValue( example::filesList; 1 ); 
"newFileName" ) = "ERROR" ] ...Handle error...

Step #5: Disconnect</p>

If[ FTPeek_Disconnect = "ERROR" ]
...Display error message to user, but we don't need to do anything else...


<a name="rel_path">Relative vs. Absolute Paths</a>

All functions support referencing remote files and directories as relative or absolute paths.</p>A relative path references files and directories starting from the current working directory. For example, if we are in the /uploaded/FTPeek/ directory on the remote server, changing into backup would navigate into the /uploaded/FTPeek/backup/ directory.
On the other hand, an absolute path references files and directories starting from the root directory of the server. If we're in the same /uploaded/FTPeek/ directory and try to change into /temp, we would actually end up in /temp/ instead of /uploaded/FTPeek/temp/, since we start at the root directory instead of the current working directory.</p> As seen in the examples, an absolute path starts with a slash /, while a relative one does not. Either can be passed in to FTPeek_ChangeDir, FTPeek_Rename, FTPeek_UploadFile, and other functions to reference relative or absolute paths.</p>


[edit] 360Works Plugin Setup Guides

See Plugins_101 for Error reporting, installation, registration, and more.

[edit] Function Summary

  • FTPeek_ChooseFile ( { initialPath ; fileType ; title } ) — Pops up a file chooser dialog.
  • FTPeek_DownloadFileToContainer ( remoteSourcePath ) — Downloads a file and returns file's data into a container field, sets transfer type for this action to Binary unless specified otherwise in FTPeek_SetTransferType( type ).
  • FTPeek_DownloadFileToField ( remoteSourcePath { ; encoding } ) — Downloads a file and returns file's data as text.
  • FTPeek_ExecuteCommand ( command ) — Requests that the remote server execute the literal command supplied.
  • FTPeek_GetCurrentDir ( ) — Returns path of current working directory on the server.
  • FTPeek_GetFileInfo ( remotePath; infoType ) — Gets information about the selected file.
  • FTPeek_GetFileList ( { remoteDir } ) — Returns a list of files in a directory as a return-separated list.
  • FTPeek_GetPublicKey ( host ) — Gets an SFTP server's public key, which must be provided as a parameter to {@link #FTPeek_ConnectSFTP}.
  • FTPeek_IsConnected ( ) — Returns connection status.
  • FTPeek_LastError ( ) — Returns detailed information about the last error generated by this plugin.
  • FTPeek_LastErrorCode ( ) — Returns the FTP reply code from the most recent FTP command that resulted in error.
  • FTPeek_LicenseInfo ( ) — Returns license information about the plugin.
  • FTPeek_ScanLocalDir ( localPath ; recursive ) — Do not use this function - it is only included for backwards compatibility and will be removed from a future version of FTPeek.
  • FTPeek_ScanLocalDirectory ( localPath ; isPathFromFileMaker ) — Scans a local directory and returns a return-separated list of files in the directory.
  • FTPeek_Version ( ) — Returns the version number of the plugin.

[edit] Function Detail

[edit] FTPeek_ChooseFile ( { initialPath ; fileType ; title } )

Pops up a file chooser dialog.

Parameters:

initialPath
optional path to set the initial dialog selection to. If empty, will default to the user's home directory.
fileType
option parameter to specify whether to allow "files", "directories", or both "files + directories".
title
optional title string to display as the title of the FileChooser dialog.

Returns: </p>
*Note that although all parameters in this function are optional, they are also positional.  This means that if you want to specify a fileType without specifying initialPath you'll need
pass in an empty string "" for the initialPath parameter.

[edit] FTPeek_DownloadFileToContainer ( remoteSourcePath )

Downloads a file and returns file's data into a container field, sets transfer type for this action to Binary unless specified otherwise in FTPeek_SetTransferType( type ). For example, this will download a Word document from the FTP server and store it into a container field:

Set Field[ example::ContainerField; 
FTPeek_DownloadFileToContainer("My report.doc") ]


Parameters:

remoteSourcePath
the file path on the remote server to download

Returns: container data with the downloaded file

[edit] FTPeek_DownloadFileToField ( remoteSourcePath { ; encoding } )

Downloads a file and returns file's data as text. For example, this will download a text file from the FTP server and store it into a text field:

Set Field[ example::TextField; 
FTPeek_DownloadFileToField("My File.txt") ]


Parameters:

remoteSourcePath
the file path on the remote server to download
encoding
optional text encoding. Some of the supported encodings are "ASCII", "ISO8859_1", "UTF8", "UTF-16", for more supported encodings consult <a href="http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html">Java supported encodings</a> use the second column of the table as the encoding name.

Returns: Text data

[edit] FTPeek_ExecuteCommand ( command )

Requests that the remote server execute the literal command supplied. In FTP and SFTP, this might be a SITE command, while in SFTP it might be a shell command. It is up to the user to send a sensible command.

Parameters:
Returns: result of the arbitrary command if one is appropriate on success, ERROR on failure

[edit] FTPeek_GetCurrentDir ( )

Returns path of current working directory on the server.
For example, if the plugin has connected and navigated into a directory called temp, calling the FTPeek_GetCurrentDir function will return /temp/.

Returns: path of current working directory

[edit] FTPeek_GetFileInfo ( remotePath; infoType )

Gets information about the selected file.

Parameters:

remotePath
remote file path to get info for.
infoType
Can be either size, which returns the file size in bytes, or moddate, which returns a Date field with the modification date of the file.


[edit] FTPeek_GetFileList ( { remoteDir } )

Returns a list of files in a directory as a return-separated list. If the directory is not specified, the contents of the current working directory are returned. The passed-in directory can be relative or absolute.

Parameters:

remoteDir
the path of the directory to look in, or empty for the current working directory

Returns: return-separated list of files in the directory

[edit] FTPeek_GetPublicKey ( host )

Gets an SFTP server's public key, which must be provided as a parameter to FTPeek_ConnectSFTP. The public key is used to check to make sure that the server you are connecting to is the same one that you originally retrieved the key from. This prevents a malicious attacker from using DNS spoofing to pose as the real FTP server. For this reason, you should get the public key the first time you connect to an FTP server, and then store that in your FileMaker database and use the same key each time you connect to the server. You could retrieve the public key every time you connect to the server, but that would defeat the purpose of this security layer.

Parameters:

host
address of the server; can be numeric IP address like "127.0.0.1" or a named one like "ftp.mysite.com"

Returns: a text representation of the server's public key

[edit] FTPeek_IsConnected ( )

Returns connection status.

Returns: 1 if connected to server, 0 if not connected

[edit] FTPeek_LastError ( )

Returns detailed information about the last error generated by this plugin. If another plugin function returns the text "ERROR", call this function to get a user-presentable description of what went wrong. For example,

If[ FTPeek_ConnectFTP( "ftp.domain.com"; "username"; "password" ) = "ERROR" ]
	Show Custom Dialog[ "Could not connect to FTP Server: " & FTPeek_LastError ]
	Exit Script
End If


Returns: Error text, or null if there was no error.

[edit] FTPeek_LastErrorCode ( )

Returns the FTP reply code from the most recent FTP command that resulted in error.

Returns: An integer if an error occurred.

[edit] FTPeek_LicenseInfo ( )

Returns license information about the plugin. This shows whether it is registered, and what type of license is being used.

Returns: plugin license information

[edit] FTPeek_ScanLocalDir ( localPath ; recursive )

Do not use this function - it is only included for backwards compatibility and will be removed from a future version of FTPeek. Use FTPeek_ScanLocalDirectory instead.

Parameters:


[edit] FTPeek_ScanLocalDirectory ( localPath ; isPathFromFileMaker )

Scans a local directory and returns a return-separated list of files in the directory. This is useful for examining the contents of a local directory to select files for upload. For example, the following call:

Set Field[ example::localFilesList; 
FTPeek_ScanLocalDirectory( "/Library/User Pictures/Animals", 0 ) ] on Mac OS X will set

the field example::localFilesList to a return separated list of files, such as

Butterfly.tif
Cat.tif
Dog.tif
Dragonfly.tif
Jaguar.tif
Parrot.tif
...etc

Calling this function on Windows:

Set Field[ example::localFilesList; 
FTPeek_ScanLocalDir( "C:\WINDOWS\Media"; 0 ) ]

will set example::localFilesList to

chimes.wav
chord.wav
ding.wav
flourish.mid
notify.wav
onestop.mid
recycle.wav
ringin.wav
ringout.wav
start.wav
tada.wav
town.mid
...etc

Directories will end in a '/' on Mac OS X or '\' on Windows.

Parameters:

localPath
path of the local folder to scan
isPathFromFileMaker
Set to 1 if localPath is a FileMaker-style path, returned from a FileMaker path function such as Get( DesktopPath ) or Get( TemporaryPath ). Set it to 0 if localPath is a native operating system path. For example, the file-style path to the user's desktop returned by Get( DesktopPath ) is '/Macintosh HD/Users/jesse/Desktop/', where the normal OS X path would be '/Users/jesse/Desktop'.

Returns: return-separated list of files in the specified directory

[edit] FTPeek_Version ( )

Returns the version number of the plugin. This is always a numeric value, with no letter characters.

Returns: the version number of the plugin
Personal tools
Namespaces

Variants
Actions
Plug-in Products
Other Products
Navigation
Toolbox