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 ¶
- type Service
- func (s *Service) Close() error
- func (s *Service) DeleteObject(ctx context.Context, objectName string) error
- func (s *Service) DownloadObject(ctx context.Context, objectName string) (io.ReadCloser, error)
- func (s *Service) ListObjectsBatch(ctx context.Context, startAfter, prefix string, batchSize int) ([]storage.ObjectInfo, error)
- func (s *Service) StatObject(ctx context.Context, key string) (storage.ObjectInfo, error)
- func (s *Service) UploadObjectReader(ctx context.Context, objectName string, r io.Reader, length int64, ...) error
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 ¶
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) DeleteObject ¶
DeleteObject removes one file. Directories cannot be deleted yet.
func (*Service) DownloadObject ¶
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 (*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.