sftp

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*sftpOptions)

Option configures an SFTP filesystem source.

func WithBasePath

func WithBasePath(basePath string) Option

WithBasePath sets the root directory on the SFTP server.

func WithClient

func WithClient(client *sftp.Client) Option

WithClient provides a pre-configured SFTP client, skipping internal connection setup. When set, server and auth options are ignored.

func WithExcludePatterns

func WithExcludePatterns(patterns []string) Option

WithExcludePatterns sets the patterns used to exclude files and folders.

func WithHostKeyCallback

func WithHostKeyCallback(cb ssh.HostKeyCallback) Option

WithHostKeyCallback sets the host key verification callback.

func WithKey

func WithKey(keyPath string) Option

WithKey sets the path to a PEM-encoded private key for authentication.

func WithKnownHosts

func WithKnownHosts(path string) Option

WithKnownHosts sets the path to the known_hosts file.

func WithPassword

func WithPassword(password string) Option

WithPassword sets password authentication.

func WithPort

func WithPort(port string) Option

WithPort sets the SSH port. Defaults to "22" when empty.

func WithUser

func WithUser(user string) Option

WithUser sets the SSH user for authentication.

type Source

type Source struct {
	// contains filtered or unexported fields
}

Source implements Source for a remote SFTP filesystem.

func New

func New(host string, opts ...Option) (*Source, error)

New creates an SFTP-backed source for the given host. Either WithClient or authentication options must be provided, along with WithBasePath.

func (*Source) Close

func (s *Source) Close() error

Close releases the underlying SFTP and SSH connections.

func (*Source) GetFileStream

func (s *Source) GetFileStream(fileID string) (io.ReadCloser, error)

func (*Source) Info

func (s *Source) Info() source.SourceInfo

func (*Source) Size

func (s *Source) Size(ctx context.Context) (*source.SourceSize, error)

func (*Source) Walk

func (s *Source) Walk(ctx context.Context, callback func(source.FileMeta) error) error

Jump to

Keyboard shortcuts

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