sftp

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package sftp is the SFTP implementation of storage.Store. Object keys are paths relative to the connection's start directory, so the rest of the app (directory tree, search, sync) works unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service talks to one SFTP server over a persistent SSH connection. It reconnects lazily when the connection drops; failed operations surface their error, the next operation runs on a fresh connection.

func New

func New(cfg config.S3Config) (*Service, error)

New connects to the SFTP server described by cfg. cfg.Endpoint is the host with an optional port (22 by default), cfg.AccessKey the username, cfg.SecretKey the password and cfg.KeyPath an optional private key file (cfg.KeyPassphrase decrypts it). cfg.Prefix is the start directory all object keys are relative to; empty means the account's home directory.

func (*Service) Close

func (s *Service) Close() error

Close shuts the connection down.

func (*Service) DeleteObject

func (s *Service) DeleteObject(ctx context.Context, objectName string) error

DeleteObject removes one file. Directories cannot be deleted yet.

func (*Service) DownloadObject

func (s *Service) DownloadObject(ctx context.Context, objectName string) (io.ReadCloser, error)

func (*Service) ListObjectsBatch

func (s *Service) ListObjectsBatch(ctx context.Context, startAfter, prefix string, batchSize int) ([]storage.ObjectInfo, error)

ListObjectsBatch lists up to batchSize objects with keys ordered lexicographically under prefix, starting after startAfter. A fresh listing (startAfter == "") walks the directory tree once; pagination and Load More (startAfter != "") serve from that cached walk. A missing prefix lists nothing, like S3 does.

func (*Service) StatObject

func (s *Service) StatObject(ctx context.Context, key string) (storage.ObjectInfo, error)

func (*Service) UploadObjectReader

func (s *Service) UploadObjectReader(ctx context.Context, objectName string, r io.Reader, length int64, mimeType string) error

UploadObjectReader writes r to the object, creating parent directories on the way. mimeType is ignored: SFTP has no content-type concept.

Jump to

Keyboard shortcuts

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