Documentation
¶
Overview ¶
Package ftpfs implements a FTP(S) client file system.
Index ¶
- Constants
- func Dial(ctx context.Context, address string, credentialsCallback CredentialsCallback, ...) (fs.FileSystem, error)
- func DialAndRegister(ctx context.Context, address string, credentialsCallback CredentialsCallback, ...) (fs.FileSystem, error)
- func EnsureRegistered(ctx context.Context, address string, credentialsCallback CredentialsCallback, ...) (free func() error, err error)
- type CredentialsCallback
Constants ¶
const ( Prefix = "ftp://" PrefixTLS = "ftps://" Separator = "/" )
Variables ¶
This section is empty.
Functions ¶
func Dial ¶
func Dial(ctx context.Context, address string, credentialsCallback CredentialsCallback, debugOut io.Writer) (fs.FileSystem, error)
Dial a new FTP or FTPS connection and registers it as file system.
The passed address can be a URL with scheme `ftp:` or `ftps:`.
func DialAndRegister ¶
func DialAndRegister(ctx context.Context, address string, credentialsCallback CredentialsCallback, debugOut io.Writer) (fs.FileSystem, error)
DialAndRegister dials a new FTP or FTPS connection and register it as file system.
The passed address can be a URL with scheme `ftp:` or `ftps:`.
func EnsureRegistered ¶
func EnsureRegistered(ctx context.Context, address string, credentialsCallback CredentialsCallback, debugOut io.Writer) (free func() error, err error)
EnsureRegistered first checks if a FTP(S) file system with the passed address is already registered. If not, then a new connection is dialed and registered. The returned free function has to be called to decrease the file system's reference count and close it when the reference count reaches 0. The returned free function will never be nil.
Types ¶
type CredentialsCallback ¶
CredentialsCallback is called by Dial to get the username and password for a SFTP connection.
func Password ¶
func Password(password string) CredentialsCallback
Password returns a CredentialsCallback that always returns the provided password together with the username from the URL that is passed to the callback.
func UsernameAndPassword ¶
func UsernameAndPassword(username, password string) CredentialsCallback
UsernameAndPassword returns a CredentialsCallback that always returns the provided username and password.