Documentation
¶
Overview ¶
Package sftp2 provides functions for interacting with a SFTP server.
Index ¶
Constants ¶
const ( DefaultPort = 22 DefaultTimeout = 5 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func CheckFileWrite ¶
func Stat ¶
Stat stats the given resource. Returns a bool indicating whether the file exists, file info, and an error if any. If the underlying error was a "does not exist" error, then the error is supressed and returns false, nil, nil If the underlying error was any other type of error, then the existence value is not guaranteed. Do check the error returned and do not ignore the error with "exists, _, _ := Stat(/path/tofile)".
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader implements the io.ReadCloser interface to enabling reading a remote file on a SFTP server and closing the underlying connections.
func Fetch ¶
func Fetch(uri string, options ...ssh2.ClientOption) (*Reader, error)
Fetch returns a Reader for a file at a given SFTP address.
Fetch returns an error if the address cannot be dialed, the userinfo cannot be parsed, the user and password are invalid, or the file cannot be retrieved.
func FetchWithKey ¶
FetchWithKey parses the provided key, appends the key to the ClientOption options, and then calls Fetch with the uri and options.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer implements the io.WriteCloser interface to enabling writing a remote file on a SFTP server and closing the underlying connections.
func NewWriter ¶
func NewWriter(file *sftp.File, sftpClient *sftp.Client, sshClient *ssh.Client, fileMode os.FileMode) *Writer
NewWriter creates a new WRiter for reading a file from a SFTP server.