sftp_toolkit v1.0.0 SFTPToolkit.Upload

Module containing functions that ease uploading data to the SFTP server.

Link to this section Summary

Functions

Uploads a single file by reading it in chunks to avoid loading whole file into memory as :ssh_sftp.write_file/3 does by default

Link to this section Functions

Link to this function

upload_file(sftp_channel_pid, local_path, remote_path, options \\ [])
upload_file(pid(), Path.t(), Path.t(),
  operation_timeout: timeout(),
  chunk_size: pos_integer(),
  remote_mode: [:read | :write | :creat | :trunc | :append | :binary],
  local_mode: [File.mode()]
) :: :ok | {:error, any()}

Uploads a single file by reading it in chunks to avoid loading whole file into memory as :ssh_sftp.write_file/3 does by default.

Arguments

Expects the following arguments:

  • sftp_channel_pid - PID of the already opened SFTP channel,
  • local_path - local path to the file,
  • remote_path - remote path to the file on the SFTP server,
  • options - additional options, see below.

Options

  • operation_timeout - SFTP operation timeout (it is a timeout per each SFTP operation, not total timeout), defaults to 5000 ms,
  • chunk_size - chunk size in bytes, defaults to 32KB,
  • remote_mode - mode used while opening the remote file, defaults to [:binary, :write, :creat], see :ssh_sftp.open/3 for possible values,
  • local_mode - mode used while opening the local file, defaults to [:binary, :read, :read_ahead], see File.open/2 for possible values.

Return values

On success returns :ok.

On error returns {:error, reason}, where reason might be one of the following: