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: 10 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(*options)

Option configures an SFTP store.

func WithBasePath

func WithBasePath(basePath string) Option

WithBasePath sets the root directory on the SFTP server.

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 WithSFTPClient

func WithSFTPClient(client *sftp.Client) Option

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

func WithUser

func WithUser(user string) Option

WithUser sets the SSH user for authentication.

type Store

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

Store implements store.ObjectStore backed by an SFTP server.

func New

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

New creates an SFTP-backed store for the given host. Either WithSFTPClient or authentication options must be provided. The base path directory is created if it does not exist.

func (*Store) Close

func (s *Store) Close() error

Close releases the underlying SFTP and SSH connections.

func (*Store) Delete

func (s *Store) Delete(_ context.Context, key string) error

func (*Store) Exists

func (s *Store) Exists(_ context.Context, key string) (bool, error)

func (*Store) Flush

func (s *Store) Flush(ctx context.Context) error

func (*Store) Get

func (s *Store) Get(_ context.Context, key string) ([]byte, error)

func (*Store) GetRange

func (s *Store) GetRange(_ context.Context, key string, offset, length int64) ([]byte, error)

GetRange implements RangeGetter by seeking, which sftp supports natively, so a caller reading a packfile footer does not transfer the whole object.

func (*Store) List

func (s *Store) List(_ context.Context, prefix string) ([]string, error)

func (*Store) Put

func (s *Store) Put(_ context.Context, key string, data []byte) error

func (*Store) Size

func (s *Store) Size(_ context.Context, key string) (int64, error)

func (*Store) TotalSize

func (s *Store) TotalSize(_ context.Context) (int64, error)

Jump to

Keyboard shortcuts

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