Documentation
¶
Index ¶
- type Config
- type FTPClient
- type FTPDownloader
- func (f *FTPDownloader) ChangeWorkingDirectory(path string) error
- func (f *FTPDownloader) Close() error
- func (f *FTPDownloader) Connect(ctx context.Context, serverURL string) error
- func (f *FTPDownloader) Download(ctx context.Context, urlStr string, writer io.Writer) error
- func (f *FTPDownloader) GetCurrentDirectory() (string, error)
- func (f *FTPDownloader) GetFileSize(ctx context.Context, urlStr string) (int64, error)
- func (f *FTPDownloader) IsConnected() bool
- func (f *FTPDownloader) ListFiles(ctx context.Context, urlStr string) ([]string, error)
- func (f *FTPDownloader) SetClient(client FTPClient)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Timeout time.Duration
DialTimeout time.Duration
Username string
Password string
TLSConfig interface{} // For FTPS support
PassiveMode bool
DebugMode bool
}
Config holds FTP connection configuration
type FTPClient ¶ added in v1.4.0
type FTPClient interface {
Login(user, password string) error
Retr(path string) (io.ReadCloser, error)
FileSize(path string) (int64, error)
List(path string) ([]*ftp.Entry, error)
Quit() error
ChangeDir(path string) error
CurrentDir() (string, error)
}
FTPClient defines the interface for FTP operations
type FTPDownloader ¶
type FTPDownloader struct {
// contains filtered or unexported fields
}
FTPDownloader handles FTP protocol downloads
func NewFTPDownloader ¶
func NewFTPDownloader(config *Config) *FTPDownloader
NewFTPDownloader creates a new FTP downloader instance
func (*FTPDownloader) ChangeWorkingDirectory ¶
func (f *FTPDownloader) ChangeWorkingDirectory(path string) error
ChangeWorkingDirectory changes the current working directory on the FTP server
func (*FTPDownloader) Connect ¶
func (f *FTPDownloader) Connect(ctx context.Context, serverURL string) error
Connect establishes a connection to the FTP server
func (*FTPDownloader) Download ¶
Download downloads a file from FTP server and writes it to the provided writer
func (*FTPDownloader) GetCurrentDirectory ¶
func (f *FTPDownloader) GetCurrentDirectory() (string, error)
GetCurrentDirectory returns the current working directory on the FTP server
func (*FTPDownloader) GetFileSize ¶
GetFileSize retrieves the size of a file on the FTP server
func (*FTPDownloader) IsConnected ¶
func (f *FTPDownloader) IsConnected() bool
IsConnected returns true if the FTP client is connected
func (*FTPDownloader) SetClient ¶ added in v1.4.0
func (f *FTPDownloader) SetClient(client FTPClient)
SetClient sets the FTP client (for testing purposes)