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 \\ [])
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/3for possible values,local_mode- mode used while opening the local file, defaults to[:binary, :read, :read_ahead], seeFile.open/2for possible values.
Return values
On success returns :ok.
On error returns {:error, reason}, where reason might be one
of the following:
{:local_open, info}- theFile.open/2on the local file failed,{:remote_open, info}- the:ssh_sftp.open/4on the remote file failed,{:upload, {:read, info}}- theIO.binread/2on the local file failed,{:upload, {:write, info}}- the:ssh_sftp.write/4on the remote file failed,{:local_close, info}- theFile.close/1on the local file failed,{:remote_close, info}- the:ssh_sftp.close/2on the remote file failed.