Documentation ¶
Overview ¶
Package FtpsClient implements a basic ftp(s) client which can be used to connect an application to a ftp server. Only a small subset of the full FTP/FTPS specification is supported
It is based on the word made by: - jlaffaye github.com/jlaffaye/ftp - smallfish github.com/smallfish/ftp - Marco Beierer github.com/webguerilla/ftps
And has some other feature such as: - Refactored with onbings coding covention - Add secure/unsecure mode - Add timeout support - Add generic Ftp control send command function (SendFtpCommand) to be able to send SITE, NOOP,... ftp command) - Fix problems in the 'LIST' result command parsing
Usage
Index ¶
- Variables
- type ConBufferSetter
- type DIRENTRYTYPE
- type DirEntry
- type FtpsClient
- func (this *FtpsClient) ChangeWorkingDirectory(_Path_S string) (rRts error)
- func (this *FtpsClient) CloseFtpDataChannel() (rReplyCode_i int, rReplyMessage_S string, rRts error)
- func (this *FtpsClient) Connect() (rRts error)
- func (this *FtpsClient) DeleteFile(_Path_S string) (rRts error)
- func (this *FtpsClient) Disconnect() (rRts error)
- func (this *FtpsClient) GetWorkingDirectory() (rDirectory_S string, rRts error)
- func (this *FtpsClient) List() (rDirEntryArray_X []DirEntry, rRts error)
- func (this *FtpsClient) MakeDirectory(_Path_S string) (rRts error)
- func (this *FtpsClient) OpenFtpDataChannel(_FtpCommand_S string, _ExpectedReplyCode_i int) (rReplyCode_i int, rReplyMessage_S string, rRts error)
- func (this *FtpsClient) ReadFtpDataChannel(_ExitAfterFirstRead_B bool, _DataArray_U8 []uint8) (rWaitDuration_S64 time.Duration, rIoDuration_S64 time.Duration, rNbRead_i int, ...)
- func (this *FtpsClient) RemoveDirectory(_Path_S string) (rRts error)
- func (this *FtpsClient) RetrieveFile(_RemoteFilepath_S, _LocalFilepath_S string) (rRts error)
- func (this *FtpsClient) SendFtpCtrlCommand(_FtpCommand_S string, _ExpectedReplyCode_i int) (rReplyCode_i int, rReplyMessage_S string, rRts error)
- func (this *FtpsClient) StoreFile(_RemoteFilepath_S string, _DataArray_U8 []byte) (rRts error)
- type FtpsClientParam
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidParameter = errors.New("Ftps: Invalid parameter") ErrNotConnected = errors.New("Ftps: Connection is not established") ErrPasv = errors.New("Ftps: Invalid PASV response format") ErrIoError = errors.New("Ftps: File transfer not complete") ErrLineFormat = errors.New("Ftps: Unsupported line format") ErrDirEntry = errors.New("Ftps: Unknown directory entry type") ErrInvalidLogin = errors.New("Ftps: Invalid loging") ErrInvalidDirectory = errors.New("Ftps: Invalid directory") ErrNotDisconnected = errors.New("Ftps: Can't disconnect") ErrSecure = errors.New("Ftps: Secure protocol error") )
Error messages generated by this package
Functions ¶
This section is empty.
Types ¶
type ConBufferSetter ¶
Interface used to fiw tx and rx buffer size
type DIRENTRYTYPE ¶
type DIRENTRYTYPE int
File type container
const ( DIRENTRYTYPE_FILE DIRENTRYTYPE = iota DIRENTRYTYPE_FOLDER DIRENTRYTYPE_LINK )
File type in a directory
type DirEntry ¶
type DirEntry struct { Type_E DIRENTRYTYPE Name_S string Ext_S string Size_U64 uint64 Time_X time.Time }
File characteristics
type FtpsClient ¶
type FtpsClient struct { FtpsParam_X FtpsClientParam // contains filtered or unexported fields }
Ftps characteristics
func NewFtpsClient ¶
func NewFtpsClient(_FtpsClientParamPtr_X *FtpsClientParam) *FtpsClient
Create a new FtpsClient based on the parameters stored in _FtpsClientParamPtr_X. Returns pointer to FtpsClient
func (*FtpsClient) ChangeWorkingDirectory ¶
func (this *FtpsClient) ChangeWorkingDirectory(_Path_S string) (rRts error)
Change the current working ftp directory Returns error object
func (*FtpsClient) CloseFtpDataChannel ¶
func (this *FtpsClient) CloseFtpDataChannel() (rReplyCode_i int, rReplyMessage_S string, rRts error)
Close ftp data channel Returns error code, reply message and error object
func (*FtpsClient) Connect ¶
func (this *FtpsClient) Connect() (rRts error)
Connect the client application to the remote ftp server Returns error object
func (*FtpsClient) DeleteFile ¶
func (this *FtpsClient) DeleteFile(_Path_S string) (rRts error)
Delete a file called '_Path_S' on the remote Ftp server Returns error object
func (*FtpsClient) Disconnect ¶
func (this *FtpsClient) Disconnect() (rRts error)
Disconnect from remote ftp server Returns error object
func (*FtpsClient) GetWorkingDirectory ¶
func (this *FtpsClient) GetWorkingDirectory() (rDirectory_S string, rRts error)
Returns the current working ftp directory Returns current working ftp directory and error object
func (*FtpsClient) List ¶
func (this *FtpsClient) List() (rDirEntryArray_X []DirEntry, rRts error)
Execute the Ftp 'LIST' command Returns the list of file object present on the ftp server and error object
func (*FtpsClient) MakeDirectory ¶
func (this *FtpsClient) MakeDirectory(_Path_S string) (rRts error)
Create a directory called '_Path_S' on the remote Ftp server Returns error object
func (*FtpsClient) OpenFtpDataChannel ¶
func (this *FtpsClient) OpenFtpDataChannel(_FtpCommand_S string, _ExpectedReplyCode_i int) (rReplyCode_i int, rReplyMessage_S string, rRts error)
Open ftp data channel based on '_FtpCommand_S' command and wait for ftp answer. Success when '_ExpectedReplyCode_i' is detected Returns error code, reply message and error object
func (*FtpsClient) ReadFtpDataChannel ¶
func (this *FtpsClient) ReadFtpDataChannel(_ExitAfterFirstRead_B bool, _DataArray_U8 []uint8) (rWaitDuration_S64 time.Duration, rIoDuration_S64 time.Duration, rNbRead_i int, rRts error)
Read data stream from ftp data channel Returns wait and io duration, number of byte read and error object
func (*FtpsClient) RemoveDirectory ¶
func (this *FtpsClient) RemoveDirectory(_Path_S string) (rRts error)
Delete a directory called '_Path_S' on the remote Ftp server Returns error object
func (*FtpsClient) RetrieveFile ¶
func (this *FtpsClient) RetrieveFile(_RemoteFilepath_S, _LocalFilepath_S string) (rRts error)
Read the file called '_RemoteFilepath_S' on the ftp remote ftp server and store its contents in local file '_RemoteFilepath_S' Returns error object
func (*FtpsClient) SendFtpCtrlCommand ¶
func (this *FtpsClient) SendFtpCtrlCommand(_FtpCommand_S string, _ExpectedReplyCode_i int) (rReplyCode_i int, rReplyMessage_S string, rRts error)
Send a ftp command '_FtpCommand_S' and wait for ftp answer. Success when '_ExpectedReplyCode_i' is detected. Returns error code, reply message and error object
type FtpsClientParam ¶
type FtpsClientParam struct { //public Id_U32 uint32 LoginName_S string LoginPassword_S string InitialDirectory_S string SecureFtp_B bool TargetHost_S string TargetPort_U16 uint16 Debug_B bool TlsConfig_X tls.Config ConnectTimeout_S64 time.Duration CtrlTimeout_S64 time.Duration DataTimeout_S64 time.Duration CtrlReadBufferSize_U32 uint32 CtrlWriteBufferSize_U32 uint32 DataReadBufferSize_U32 uint32 DataWriteBufferSize_U32 uint32 }
Ftps client working parameters