Sidereon.GNSS.FtpClient (Sidereon v0.36.4)

Copy Markdown View Source

Minimal anonymous-FTP client implementation over :gen_tcp.

Replaces Erlang/OTP's legacy :ftp application (removed in OTP 30) for retrieving open GNSS archive files and listings over FTP.

Test Seams

  • :ftp_port - Configured via Application.get_env(:sidereon, :ftp_port, 21). Allows overriding the default control port (21) for local test servers.

Summary

Functions

Returns a specification to start this module under a supervisor.

Closes the FTP connection.

Lists contents of a directory.

Opens an FTP control connection to host.

Retrieves the next chunk of the file or signals EOF (:ok).

Starts retrieving a file.

Sets transfer mode (e.g. :binary for TYPE I).

Authenticates with the FTP server (typically anonymous).

Types

host()

@type host() :: charlist() | String.t() | :inet.ip_address()

opt()

@type opt() :: {:timeout, pos_integer()} | {:mode, :passive | :active}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(pid)

@spec close(pid()) :: :ok

Closes the FTP connection.

ls(pid, path)

@spec ls(pid(), charlist() | String.t()) ::
  {:ok, binary()} | {:error, :epath} | {:error, term()}

Lists contents of a directory.

open(host, opts)

@spec open(host(), [opt()]) :: {:ok, pid()} | {:error, term()}

Opens an FTP control connection to host.

recv_chunk(pid)

@spec recv_chunk(pid()) :: :ok | {:ok, binary()} | {:error, :epath} | {:error, term()}

Retrieves the next chunk of the file or signals EOF (:ok).

recv_chunk_start(pid, path)

@spec recv_chunk_start(pid(), charlist() | String.t()) ::
  :ok | {:error, :epath} | {:error, term()}

Starts retrieving a file.

type(pid, mode)

@spec type(pid(), :binary | :ascii) :: :ok | {:error, :epath} | {:error, term()}

Sets transfer mode (e.g. :binary for TYPE I).

user(pid, user, pass)

@spec user(pid(), charlist() | String.t(), charlist() | String.t()) ::
  :ok | {:error, :epath} | {:error, term()}

Authenticates with the FTP server (typically anonymous).