Documentation ¶
Index ¶
- func KeyFilePath(filename string) (path string)
- func UserHomeDir() (homedir string)
- type CallbackFunc
- type SFTPConnection
- func (sftpConnection *SFTPConnection) Close() error
- func (sftpConnection *SFTPConnection) DownloadFiles(source string, target string) error
- func (sftpConnection *SFTPConnection) RemoveFile(sourcePath string) error
- func (sftpConnection *SFTPConnection) UploadFile(sourcePath, targetPath string) error
- func (sftpConnection *SFTPConnection) WalkDirectories(path string, callback CallbackFunc) error
- func (sftpConnection *SFTPConnection) WalkFiles(path string, callback CallbackFunc) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyFilePath ¶
KeyFilePath : Gets Key File Path - User Home directory + .ssh + key file name
Types ¶
type CallbackFunc ¶
type CallbackFunc func(sftpConnection *SFTPConnection, filePath string, fileName string)
CallbackFunc : Callback function template
type SFTPConnection ¶
SFTPConnection : Main connection
func ConnectWithKeyFile ¶
func ConnectWithKeyFile(host, username, privkeyfile string) (*SFTPConnection, error)
ConnectWithKeyFile : This function will get an sftp conenction using the private key file Returns client ssh connection handler and error object if fails Host - ftp server name with or without port Username - ftp user (e.g ec2-user) privkeyfile - Fully qualified Private key file name
func ConnectWithPassword ¶
func ConnectWithPassword(host, username, password string) (*SFTPConnection, error)
ConnectWithPassword : This function will get an sftp conenction using a password Returns client ssh connection handler and error object if fails Host - sftp server name with or without port Username - sftp user (e.g ec2-user) password - password for sftp user
func (*SFTPConnection) Close ¶
func (sftpConnection *SFTPConnection) Close() error
Close : Close the SFTP Session
func (*SFTPConnection) DownloadFiles ¶
func (sftpConnection *SFTPConnection) DownloadFiles(source string, target string) error
DownloadFiles : This function will download all files from ftp_server folder to the folder including sub-folders Return: error if fails source - remote Source directory target - local TargetDir
func (*SFTPConnection) RemoveFile ¶
func (sftpConnection *SFTPConnection) RemoveFile(sourcePath string) error
RemoveFile : Removes a file from FTP Server
func (*SFTPConnection) UploadFile ¶
func (sftpConnection *SFTPConnection) UploadFile(sourcePath, targetPath string) error
UploadFile : Copy source file to target
func (*SFTPConnection) WalkDirectories ¶
func (sftpConnection *SFTPConnection) WalkDirectories(path string, callback CallbackFunc) error
WalkDirectories : Iterates over all the inner directories and calls a processing function
func (*SFTPConnection) WalkFiles ¶
func (sftpConnection *SFTPConnection) WalkFiles(path string, callback CallbackFunc) error
WalkFiles : Iterates over all the inner files in the remote directory and calls a processing function