ftpasta

Types

Configuration struct for building FTP connections.

pub type Config {
  Config(
    host: String,
    port: Int,
    tls: tls_config.TLSConfig,
    verify: Bool,
    username: String,
    password: String,
  )
}

Constructors

  • Config(
      host: String,
      port: Int,
      tls: tls_config.TLSConfig,
      verify: Bool,
      username: String,
      password: String,
    )

Type representing an FTP connection.

pub opaque type Connection

Remote file type.

pub type Listing {
  Directory(name: String)
  File(name: String, size: Int)
  Link(name: String, target: String)
}

Constructors

  • Directory(name: String)
  • File(name: String, size: Int)
  • Link(name: String, target: String)

Values

pub fn append_bytes(
  connection: Connection,
  data: BitArray,
  remote_file: String,
) -> Result(Nil, ftp_error.FTPError)

Append some data onto a file on the server.

pub fn append_file(
  connection: Connection,
  local_file: String,
  remote_file: String,
) -> Result(Nil, ftp_error.FTPError)

Append a file to another file on the server.

pub fn auth(
  config: Config,
  username: String,
  password: String,
) -> Config

Provide a username and password.

pub fn change_working_dir(
  connection: Connection,
  remote_dir: String,
) -> Result(Nil, ftp_error.FTPError)

Change directories on the remote server.

pub fn close(connection: Connection) -> Nil

Close the connection.

pub fn connect(
  config: Config,
) -> Result(Connection, ftp_error.FTPError)

Connect to the server.

pub fn create_dir(
  connection: Connection,
  remote_dir: String,
) -> Result(Nil, ftp_error.FTPError)

Create a new directory on the server.

pub fn delete_dir(
  connection: Connection,
  remote_dir: String,
) -> Result(Nil, ftp_error.FTPError)

Remove an empty directory from the server.

pub fn delete_file(
  connection: Connection,
  remote_file: String,
) -> Result(Nil, ftp_error.FTPError)

Remove a file from the server.

pub fn delete_recursive(
  connection: Connection,
  remote_dir: String,
) -> Result(Nil, ftp_error.FTPError)

Remove a directory and all contents from the server.

pub fn describe_error(error: ftp_error.FTPError) -> String

Convert an FTPError into a descriptive string.

pub fn download_bytes(
  connection: Connection,
  remote_file: String,
) -> Result(BitArray, ftp_error.FTPError)

Fetch a file from the server, and return it as a BitArray.

pub fn download_file(
  connection: Connection,
  remote_file: String,
  local_file: String,
) -> Result(Nil, ftp_error.FTPError)

Fetch a file from the server.

pub fn download_recursive(
  connection: Connection,
  remote_dir: String,
  local_dir: String,
) -> Result(Nil, ftp_error.FTPError)

Fetch a directory and all contents recursively from the server.

pub fn encryption(
  config: Config,
  tls: tls_config.TLSConfig,
) -> Config

Use encryption.

pub fn get_working_dir(
  connection: Connection,
) -> Result(String, ftp_error.FTPError)

Get the current remote path used for the connection.

pub fn list(
  connection: Connection,
  remote_dir: String,
) -> Result(List(Listing), ftp_error.FTPError)

List all files, symlinks, and subdirectories in a directory.

pub fn new(host: String) -> Config

Start building an FTP connection.

pub fn port(config: Config, port: Int) -> Config

Use a non-default port.

pub fn rename(
  connection: Connection,
  old_path: String,
  new_path: String,
) -> Result(Nil, ftp_error.FTPError)

Rename a file or directory on the server.

pub fn upload_bytes(
  connection: Connection,
  data: BitArray,
  remote_file: String,
) -> Result(Nil, ftp_error.FTPError)

Send a data in memory to the server.

pub fn upload_file(
  connection: Connection,
  local_file: String,
  remote_file: String,
) -> Result(Nil, ftp_error.FTPError)

Send a file to the server.

pub fn upload_recursive(
  connection: Connection,
  local_dir: String,
  remote_dir: String,
) -> Result(Nil, ftp_error.FTPError)

Send a directory and all contents to the server.

pub fn verification(config: Config, enabled: Bool) -> Config

How to verify certificates.

Search Document