sftpdriver

package module
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package sftpdriver provides an SFTP storage driver for Trove.

The SFTP driver stores objects as files on a remote server accessed via SSH/SFTP. Buckets map to subdirectories under a configurable base path. Object metadata is stored in sidecar .meta.json files (following localdriver pattern).

DSN format:

sftp://user:pass@host:22/basepath
sftp://user@host/basepath?key=/path/to/key

Usage:

drv := sftpdriver.New()
drv.Open(ctx, "sftp://deploy:secret@files.example.com:22/data/storage")
t, err := trove.Open(drv)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SFTPDriver

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

SFTPDriver implements driver.Driver using SFTP.

func New

func New() *SFTPDriver

New creates a new SFTP storage driver.

func Unwrap

func Unwrap(t interface{ Driver() driver.Driver }) *SFTPDriver

Unwrap extracts the typed SFTPDriver from a Trove handle.

func (*SFTPDriver) Client

func (d *SFTPDriver) Client() *sftp.Client

Client returns the underlying SFTP client for advanced use cases.

func (*SFTPDriver) Close

func (d *SFTPDriver) Close(_ context.Context) error

Close disconnects the SFTP and SSH connections.

func (*SFTPDriver) Copy

func (d *SFTPDriver) Copy(_ context.Context, srcBucket, srcKey, dstBucket, dstKey string, opts ...driver.CopyOption) (*driver.ObjectInfo, error)

Copy copies an object within or across buckets.

func (*SFTPDriver) CreateBucket

func (d *SFTPDriver) CreateBucket(_ context.Context, name string, _ ...driver.BucketOption) error

CreateBucket creates a subdirectory under the base path.

func (*SFTPDriver) Delete

func (d *SFTPDriver) Delete(_ context.Context, bucket, key string, _ ...driver.DeleteOption) error

Delete removes an object from the remote SFTP server.

func (*SFTPDriver) DeleteBucket

func (d *SFTPDriver) DeleteBucket(_ context.Context, name string) error

DeleteBucket removes a bucket subdirectory.

func (*SFTPDriver) Get

func (d *SFTPDriver) Get(_ context.Context, bucket, key string, _ ...driver.GetOption) (*driver.ObjectReader, error)

Get retrieves an object from the remote SFTP server.

func (*SFTPDriver) Head

func (d *SFTPDriver) Head(_ context.Context, bucket, key string) (*driver.ObjectInfo, error)

Head returns object metadata without content.

func (*SFTPDriver) List

func (d *SFTPDriver) List(_ context.Context, bucket string, opts ...driver.ListOption) (*driver.ObjectIterator, error)

List returns objects matching the given options.

func (*SFTPDriver) ListBuckets

func (d *SFTPDriver) ListBuckets(_ context.Context) ([]driver.BucketInfo, error)

ListBuckets returns all bucket directories.

func (*SFTPDriver) Name

func (d *SFTPDriver) Name() string

Name returns "sftp".

func (*SFTPDriver) Open

func (d *SFTPDriver) Open(_ context.Context, dsn string, _ ...driver.Option) error

Open initializes the SFTP connection using the given DSN.

func (*SFTPDriver) Ping

func (d *SFTPDriver) Ping(_ context.Context) error

Ping verifies SFTP connectivity by stat'ing the base path.

func (*SFTPDriver) Put

func (d *SFTPDriver) Put(_ context.Context, bucket, key string, r io.Reader, opts ...driver.PutOption) (*driver.ObjectInfo, error)

Put stores an object on the remote SFTP server.

Jump to

Keyboard shortcuts

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