SFTP Module

The SFTP module allows interaction with directories and files on a SFTP server.

SFTP module functions

directoryExists

Signature: (path: text) -> boolean.

Determines whether a directory exists at the specified path.

Output: Returns True if the directory exists, False otherwise.

//path to the directory
let path = @"/upload";

return SFTP.directoryExists(path);

//The path parameter can be passed as inline value as well.
return SFTP.directoryExists(@"/upload");

createDirectory

Signature: (path: text)

Creates a directory at the SFTP server. It is not possible to create several levels of directories in one step. If you want to create the directory "./dirA/dirB", the directory "./dirA" must exist. Otherwise you have to do it in two steps; first creates directory "./dirA" and the second one created "./dirA/dirB"

Output: no output.

deleteDirectory

Signature: (path: text, options: {recursive: true})

Deletes specified directory. Note that the directory must be empty unless Recursive is set to true.

Output: No output.

listDirectories

Signature: listDirectories(path: text, mask: text, options: {ListOptions}) -> text*.

Lists all files and directories in a specified path. Mask can be used when filtering items in directory. Regular expressions can also be used by prefixing with "regex:"

Optional parameter ListOptions has few properties.

  • caseSensitive: boolean - indicates whether to ignore casing or not. Default is false

  • recursive: boolean - indicates whether to include nested subdirectories recursively. Default is false.

  • include: text - indicates whether to include files or/and directories in the listing

    • All - include both files and directories

    • FilesOnly - include only files

    • DirectoriesOnly - include only directories

Output: Returns a sequence of records where each record contains,

  • Name: text - name of the file or directory

  • Size: number - size in bytes

  • IsDirectory: boolean - true if its a directory, false otherwise

  • LastAccessTime: date - Last time item was accessed

  • LastModifiedTime: date - Last time item was modified

  • CreationTime: date - Time of item creation

fileExists

Signature: (path: text) -> boolean.

Checks if a remote file exists.

Output: true if file exists. false otherwise.

getFileSize

Signature: (path: text) -> number.

Gets the size, in bytes, of a remote file.

Output: Returns the byte value of the file

renameFile

Signature: (oldPath: text, newPath: text)

Rename a remote file.

Output: no output

copyFile

circle-exclamation

copyFile operation only works if the connecting SFTP server supports it. The standard SFTP protocol does not have a direct remote-to-remote copy command. Hence most of the SFTP server does not have native support for copying files.

Signature: (remoteSourcePath: text, remoteDestinationPath: text, options: {OverwriteIfExistsOptions})

Copies a remote file into the selected destination.

Output: no output

deleteFile

Signature: (path: text)

Delete a remote file.

Output: no output

deleteFiles

Signature: (remotePath: text, remoteMask: text, options: {DeleteFilesOptions})

Delete multiple remote files based on mask. Optional parameter DeleteFilesOptions has following properties.

  • caseSensitive: boolean - indicates whether to ignore casing or not. Default is false

  • recursive: boolean - indicates whether to include nested subdirectories recursively. Default is false.

Output: no output

uploadFile

Signature: (localFilename: text, remoteFilename: text, options: {UploadOptions})

Uploads a single file to the SFTP Server. Optional parameter UploadOptions has following properties.

  • fileTransferMode: text - specifies the behavior if the file already exists.

    • "Overwrite" - Replace the destination file if it exists. Default option

    • "OverwriteIfDifferentSize" - Overwrite only if the destination file size is different

    • "AppendToEnd" - Append content to the end of the existing file

    • "Resume" - Resume a partially transferred file

    • "Skip" - Skip the transfer if the file already exists

  • restartPosition: number - Can be used to resume a broken transfer operation. If set to a non-zero positive value, the file being transferred is read starting from that position and is written also starting from provided position.The default value is -1.

Output: no output

uploadFiles

Signature: (localPath: text, remotePath: text, localMask: text, options: {UploadMultipleOptions})

Uploads multiple files to the SFTP Server. mask can be used to filter which files to upload. Regular expressions can also be used by prefixing with "regex:"

Optional parameter UploadMultipleOptions has following properties.

  • caseSensitive: boolean - indicates whether to ignore casing or not. Default is false

  • fileTransferMode: text - specifies the behavior if the file already exists.

    • "Overwrite" - Replace the destination file if it exists. Default option

    • "OverwriteIfDifferentSize" - Overwrite only if the destination file size is different

    • "AppendToEnd" - Append content to the end of the existing file

    • "Resume" - Resume a partially transferred file

    • "Skip" - Skip the transfer if the file already exists

  • recursive: boolean - indicates whether to include nested subdirectories recursively. Default is false.

Output: no output

uploadStream

Signature: (localStream: binary, remoteFilename: text, options: {UploadOptions})

Uploads the content of a Flow variable that contains a binary stream. This can for instance be used to upload data from a camera input. Optional parameter UploadOptions has following properties.

  • fileTransferMode: text - specifies the behavior if the file already exists.

    • "Overwrite" - Replace the destination file if it exists. Default option

    • "OverwriteIfDifferentSize" - Overwrite only if the destination file size is different

    • "AppendToEnd" - Append content to the end of the existing file

    • "Resume" - Resume a partially transferred file

    • "Skip" - Skip the transfer if the file already exists

  • restartPosition: number - Can be used to resume a broken transfer operation. If set to a non-zero positive value, the file being transferred is read starting from that position and is written also starting from provided position.The default value is -1.

Output: no output

downloadFile

Signature: (remotePath: text, localPath: text, options: {UploadMultipleOptions})

Uploads multiple files to the SFTP Server. mask can be used to filter which files to upload. Regular expressions can also be used by prefixing with "regex:"

Optional parameter UploadMultipleOptions has following properties.

  • caseSensitive: boolean - indicates whether to ignore casing or not. Default is false

  • fileTransferMode: text - specifies the behavior if the file already exists.

    • "Overwrite" - Replace the destination file if it exists. Default option

    • "OverwriteIfDifferentSize" - Overwrite only if the destination file size is different

    • "AppendToEnd" - Append content to the end of the existing file

    • "Resume" - Resume a partially transferred file

    • "Skip" - Skip the transfer if the file already exists

  • recursive: boolean - indicates whether to include nested subdirectories recursively. Default is false.

Output: no output

downloadFiles

Signature: (remotePath: text, localPath: text, remoteMask:text, options: {DownloadMultipleOptions})

Download multiple files from the SFTP server to the machine where Flow Connect agent is running. remote mask can be used to filter which files to download. Regular expressions can also be used by prefixing with "regex:"

Optional parameter DownloadMultipleOptions has following properties.

  • caseSensitive: boolean - indicates whether to ignore casing or not. Default is false

  • fileTransferMode: text - specifies the behavior if the file already exists.

    • "Overwrite" - Replace the destination file if it exists. Default option

    • "OverwriteIfDifferentSize" - Overwrite only if the destination file size is different

    • "AppendToEnd" - Append content to the end of the existing file

    • "Resume" - Resume a partially transferred file

    • "Skip" - Skip the transfer if the file already exists

  • fileCopyMode: text - specifies what to do with the original file after download has been completed.

    • "Copy" - Copies the file to the destination without deleting the original. Default option

    • "CopyAndDeleteImmediate" - Copies the file, then immediately deletes the source file after a successful copy

    • "CopyAndDeleteOnCompletion" - Copies the file, but deletes the source only after all transfer or post-processing operations are fully completed

  • recursive: boolean - indicates whether to include nested subdirectories recursively. Default is false.

Output: no output

downloadStream

Signature: (remoteFilename: text)

Download a file from SFTP server and store it as Flow variable.

Output: Raw binary content

Last updated

Was this helpful?