ftpfs

package module
v0.0.0-...-a606985 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package ftpfs implements a FTP(S) client file system.

Index

Constants

View Source
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

type CredentialsCallback func(*url.URL) (username, password string, err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL