Documentation ¶
Index ¶
- Variables
- type Configuration
- type Dialer
- type FTP
- func (f *FTP) Connect() (conn ServerConnexion, err error)
- func (f *FTP) CreateDir(sPath string) (err error)
- func (f *FTP) CreateFile(sPath string, reader io.Reader) error
- func (f *FTP) Download(ctx context.Context, src, dst string) (err error)
- func (f *FTP) DownloadReader(src string) (conn ServerConnexion, r io.ReadCloser, err error)
- func (f *FTP) Exists(sFilePath string) (b bool, err error)
- func (f *FTP) FileSize(src string) (s int64, err error)
- func (f *FTP) GetExtensionFile(oFile *ftp.Entry) string
- func (f *FTP) GetFileNameWithoutExtension(sFileName string) string
- func (f *FTP) List(sFolder string, aExtensionsAllowed []string, sPattern string) []*ftp.Entry
- func (f *FTP) ListFolders(sFolder string) []*ftp.Entry
- func (f *FTP) Remove(src string) (err error)
- func (f *FTP) RemoveDir(sPath string) (err error)
- func (f *FTP) RemoveDirRecur(sPath string) (err error)
- func (f *FTP) Rename(sSource string, sDestination string) (err error)
- func (f *FTP) Upload(ctx context.Context, src, dst string) (err error)
- func (f *FTP) UploadReader(ctx context.Context, reader io.Reader, dst string) error
- type ServerConnexion
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Addr = flag.String("ftp-addr", "", "the ftp addr") Password = flag.String("ftp-password", "", "the ftp password") Timeout = flag.Duration("ftp-timeout", 0, "the ftp timeout") Username = flag.String("ftp-username", "", "the ftp username") )
Flags
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { Addr string `json:"addr"` Password string `json:"password"` Timeout time.Duration `toml:"timeout"` Username string `json:"username"` }
Configuration represents the FTP configuration
func FlagConfig ¶
func FlagConfig() Configuration
FlagConfig generates a Configuration based on flags
type Dialer ¶
type Dialer interface { Dial(addr string) (conn ServerConnexion, err error) DialTimeout(addr string, timeout time.Duration) (conn ServerConnexion, err error) }
type FTP ¶
type FTP struct { Addr string Password string Timeout time.Duration Username string // contains filtered or unexported fields }
FTP represents an FTP
func New ¶
func New(c Configuration, dialer Dialer) *FTP
New creates a new FTP connection based on a configuration
func (*FTP) Connect ¶
func (f *FTP) Connect() (conn ServerConnexion, err error)
Connect connects to the FTP and logs in
func (*FTP) CreateFile ¶
CreateFile in folder with content in param
func (*FTP) DownloadReader ¶
func (f *FTP) DownloadReader(src string) (conn ServerConnexion, r io.ReadCloser, err error)
DownloadReader returns the reader built from the download of a file
func (*FTP) GetExtensionFile ¶
GetExtensionFile do
func (*FTP) GetFileNameWithoutExtension ¶
GetFileNameWithoutExtension do
func (*FTP) RemoveDirRecur ¶
RemoveDirRecur do
type ServerConnexion ¶
type ServerConnexion interface { Login(sUsername string, sPwd string) error Retr(path string) (*ftp.Response, error) FileSize(path string) (int64, error) Stor(path string, oReader io.Reader) error MakeDir(sSource string) error RemoveDir(sSource string) error RemoveDirRecur(sSource string) error Rename(sSource string, sDestination string) error Delete(oath string) error Quit() error List(sPath string) ([]*ftp.Entry, error) }
Click to show internal directories.
Click to hide internal directories.