Documentation
¶
Overview ¶
Package sftp provides high-performance SFTP and SCP file transfer services over SSH sessions.
Index ¶
- Variables
- func Download(sshClient *ssh.Client, remotePath, localPath string, maxPacketSize uint32) error
- func DownloadParallel(ctx context.Context, sshClient *ssh.Client, remotePath, localPath string, ...) error
- func NewClient(sshClient *ssh.Client, maxPacketSize uint32, opts ...pkgsftp.ClientOption) (*pkgsftp.Client, error)
- func Scp(ctx context.Context, sshClient *ssh.Client, ...) error
- func Upload(sshClient *ssh.Client, localPath, remotePath string, maxPacketSize uint32) error
- func UploadParallel(ctx context.Context, sshClient *ssh.Client, localPath, remotePath string, ...) error
- func WriteFile(ctx context.Context, sshClient *ssh.Client, r io.Reader, size int64, ...) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidTargetFile is returned when a target SCP filename contains control characters (\r, \n, \x00). ErrInvalidTargetFile = errors.New("aoni/ssh/sftp: invalid control characters in target filename") // ErrInvalidChunkSize is returned when parallel transfer chunkSize is less than or equal to zero. ErrInvalidChunkSize = errors.New("aoni/ssh/sftp: parallel chunk size must be greater than zero") // ErrParallelTransferFailed is returned when one or more chunks fail during parallel file transfer. ErrParallelTransferFailed = errors.New("aoni/ssh/sftp: parallel file transfer failed") // ErrClientClosed is returned when operations are attempted on an inactive or nil SSH client. ErrClientClosed = errors.New("aoni/ssh/sftp: ssh client session is closed") )
Functions ¶
func Download ¶
Download transfers a remote file to localPath over SFTP using pooled buffers and flushes disk writes.
func DownloadParallel ¶
func DownloadParallel( ctx context.Context, sshClient *ssh.Client, remotePath, localPath string, workers int, chunkSize int64, maxPacketSize uint32, ) error
DownloadParallel downloads a remote file to localPath over SFTP using multiple parallel worker threads reading at calculated offsets.
func NewClient ¶
func NewClient(sshClient *ssh.Client, maxPacketSize uint32, opts ...pkgsftp.ClientOption) (*pkgsftp.Client, error)
NewClient initializes a new SFTP client over the active SSH connection using asynchronous write/read pipelining.
func Scp ¶
Scp uploads localFilePath to remoteFilePath on the remote machine using native SCP protocol with zero-alloc buffer pooling.
func UploadParallel ¶
func UploadParallel( ctx context.Context, sshClient *ssh.Client, localPath, remotePath string, workers int, chunkSize int64, maxPacketSize uint32, ) error
UploadParallel uploads a local file to remotePath over SFTP using multiple parallel worker threads writing at calculated offsets.
Types ¶
This section is empty.