Documentation
¶
Overview ¶
Package sftpstorage provides a host-verified SFTP driver with atomic destination replacement. Put and Move require the server's posix-rename extension; the driver returns the server error instead of falling back to a non-atomic replacement.
The SSH client dial API cannot be interrupted by context cancellation once dialing begins. NewContext checks cancellation before dialing and bounds the dial with the configured SSH timeout; streaming operations check cancellation between reads and writes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(cfg Config) (storagecore.Storage, error)
New constructs SFTP-backed storage using ssh and pkg/sftp. @group Driver Constructors
Example: sftp storage
fs, _ := sftpstorage.New(sftpstorage.Config{
Host: "127.0.0.1",
User: "demo",
Password: "secret",
})
_ = fs
func NewContext ¶
NewContext validates cfg and establishes an SFTP session.
Types ¶
type Config ¶
type Config struct {
Host string
Port int
User string
Password string
KeyPath string
KnownHostsPath string
InsecureIgnoreHostKey bool
Prefix string
}
Config defines an SFTP-backed storage disk. @group Driver Config
Example: define sftp storage config
cfg := sftpstorage.Config{
Host: "127.0.0.1",
User: "demo",
Password: "secret",
}
_ = cfg
Example: define sftp storage config with all fields
cfg := sftpstorage.Config{
Host: "127.0.0.1",
Port: 22, // default: 22
User: "demo", // default: "root"
Password: "secret", // default: ""
KeyPath: "/path/id_ed25519", // default: ""
KnownHostsPath: "/path/known_hosts", // default: ""
InsecureIgnoreHostKey: false, // default: false
Prefix: "uploads", // default: ""
}
_ = cfg
func (Config) DriverName ¶
DriverName returns the registry identifier for SFTP storage.
func (Config) ResolvedConfig ¶
func (c Config) ResolvedConfig() storagecore.ResolvedConfig
ResolvedConfig maps SSH, authentication, and prefix settings into storagecore.