ByteChef LogoByteChef

FTP

FTP (File Transfer Protocol) is a standard network protocol for transferring files between a client and a server. It allows uploading, downloading, and managing files on remote servers.

Categories: File Storage, Helpers

Type: ftp/v1


Connections

Version: 1

custom

Properties

NameLabelTypeDescriptionRequired
hostHostSTRINGThe hostname or IP address of the FTP server.true
portPortINTEGERThe port number of the server. Defaults to 21 for FTP and 22 for SFTP if not specified.false
usernameUsernameSTRINGThe username for authentication.true
passwordPasswordSTRINGThe password for authentication.true
passiveModePassive ModeBOOLEAN
Options true, false
Use passive mode for data connections. Recommended when the server is behind a firewall. Only applicable for FTP connections.false
sftpUse SFTPBOOLEAN
Options true, false
Use SFTP (SSH File Transfer Protocol) instead of FTP. SFTP provides encrypted file transfer over SSH. When enabled, the port defaults to 22 instead of 21.false

Actions

Upload File

Name: uploadFile

Uploads a file to the FTP/SFTP server.

Properties

NameLabelTypeDescriptionRequired
fileEntryFileFILE_ENTRYThe file to upload.true
pathRemote PathSTRINGThe path on the server where the file should be uploaded (including filename).true
createDirectoriesCreate DirectoriesBOOLEAN
Options true, false
Create the directory structure on the server if it does not exist.false

Example JSON Structure

{
  "label" : "Upload File",
  "name" : "uploadFile",
  "parameters" : {
    "fileEntry" : {
      "extension" : "",
      "mimeType" : "",
      "name" : "",
      "url" : ""
    },
    "path" : "",
    "createDirectories" : false
  },
  "type" : "ftp/v1/uploadFile"
}

Output

Sample Output:

{remotePath=/uploads/document.pdf, success=true}

Type: OBJECT

Properties

NameTypeDescription
remotePathSTRINGThe path where the file was uploaded.
successBOOLEAN
Options true, false
Whether the upload was successful.

Output Example

{
  "remotePath" : "",
  "success" : false
}

Download File

Name: downloadFile

Downloads a file from the FTP/SFTP server.

Properties

NameLabelTypeDescriptionRequired
pathRemote PathSTRINGThe path of the file on the server to download.true

Example JSON Structure

{
  "label" : "Download File",
  "name" : "downloadFile",
  "parameters" : {
    "path" : ""
  },
  "type" : "ftp/v1/downloadFile"
}

Output

Type: FILE_ENTRY

Properties

NameTypeDescription
extensionSTRING
mimeTypeSTRING
nameSTRING
urlSTRING

Output Example

{
  "extension" : "",
  "mimeType" : "",
  "name" : "",
  "url" : ""
}

List Directory

Name: list

Lists the contents of a directory on the FTP/SFTP server.

Properties

NameLabelTypeDescriptionRequired
pathPathSTRINGThe path of the directory to list.true
recursiveRecursiveBOOLEAN
Options true, false
List files recursively in subdirectories.false

Example JSON Structure

{
  "label" : "List Directory",
  "name" : "list",
  "parameters" : {
    "path" : "",
    "recursive" : false
  },
  "type" : "ftp/v1/list"
}

Output

Type: ARRAY

Items Type: OBJECT

Properties

NameTypeDescription
nameSTRINGName of the file or directory.
pathSTRINGFull path to the file or directory.
typeSTRINGType: 'file' or 'directory'.
sizeINTEGERSize in bytes (for files).
modifiedAtSTRINGLast modified timestamp.

Output Example

[ {
  "name" : "",
  "path" : "",
  "type" : "",
  "size" : 1,
  "modifiedAt" : ""
} ]

Delete

Name: delete

Deletes a file or directory from the FTP/SFTP server.

Properties

NameLabelTypeDescriptionRequired
pathPathSTRINGThe path of the file or directory to delete.true
recursiveRecursiveBOOLEAN
Options true, false
If the path is a directory, delete all contents recursively.false

Example JSON Structure

{
  "label" : "Delete",
  "name" : "delete",
  "parameters" : {
    "path" : "",
    "recursive" : false
  },
  "type" : "ftp/v1/delete"
}

Output

Sample Output:

{success=true, deletedPath=/uploads/old-file.pdf}

Type: OBJECT

Properties

NameTypeDescription
deletedPathSTRINGThe path that was deleted.
successBOOLEAN
Options true, false
Whether the deletion was successful.

Output Example

{
  "deletedPath" : "",
  "success" : false
}

Rename/Move

Name: rename

Renames or moves a file or directory on the FTP/SFTP server.

Properties

NameLabelTypeDescriptionRequired
oldPathSource PathSTRINGThe current path of the file or directory.true
newPathDestination PathSTRINGThe new path for the file or directory.true
createDirectoriesCreate DirectoriesBOOLEAN
Options true, false
Create the destination directory structure if it does not exist.false

Example JSON Structure

{
  "label" : "Rename/Move",
  "name" : "rename",
  "parameters" : {
    "oldPath" : "",
    "newPath" : "",
    "createDirectories" : false
  },
  "type" : "ftp/v1/rename"
}

Output

Sample Output:

{newPath=/archive/new-name.pdf, oldPath=/uploads/old-name.pdf, success=true}

Type: OBJECT

Properties

NameTypeDescription
oldPathSTRINGThe original path.
newPathSTRINGThe new path.
successBOOLEAN
Options true, false
Whether the operation was successful.

Output Example

{
  "oldPath" : "",
  "newPath" : "",
  "success" : false
}

How is this guide?

Last updated on

On this page