sftp_ex v0.1.0 SFTP.Service

Provides methods for connecting to a server through SFTP, and downloading files from the server.

Summary

Functions

Closes an open SFTP channel given a channel_pid and file handle

Creates an SFTP connection

Similar to IO.each_binstream this returns a tuple with the data and the file handle if data is read from the server. If it reaches the end of the file then {:halt, handle} is returned where handle is the file handle

Opens a file given a channel PID and path. {:ok, handle} if successful, {:error, reason} otherwise

Downloads a remote path {:ok, data} if successful, {:error, reason} if unsuccessful

Writes a file to a remote path given a file, path, and open channel

Writes data to a open file using the channel PID

Functions

close(channel_pid, handle, path)

Closes an open SFTP channel given a channel_pid and file handle

connect(host, port, opts)

Creates an SFTP connection

Available Options see http://erlang.org/doc/man/ssh.html#connect-3

each_binstream(channel_pid, handle, byte_length)

Similar to IO.each_binstream this returns a tuple with the data and the file handle if data is read from the server. If it reaches the end of the file then {:halt, handle} is returned where handle is the file handle

open(channel_pid, path, opts)

Opens a file given a channel PID and path. {:ok, handle} if successful, {:error, reason} otherwise

read_and_download(channel_pid, remote_path)

Downloads a remote path {:ok, data} if successful, {:error, reason} if unsuccessful

upload(channel_pid, remote_path, file)

Writes a file to a remote path given a file, path, and open channel

write(channel_pid, handle, data)

Writes data to a open file using the channel PID