Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) Cwd() (string, error)
- func (c *Client) Download(ctx context.Context, remotePath, localPath string, progress ProgressCallback) error
- func (c *Client) DownloadDirectory(ctx context.Context, remoteDir, localDir string, progress ProgressCallback) error
- func (c *Client) DownloadFile(ctx context.Context, remotePath, localPath string, size int64, ...) error
- func (c *Client) JoinPath(elem ...string) string
- func (c *Client) NewShell(stdin io.Reader, stdout, stderr io.Writer) (*Shell, error)
- func (c *Client) SFTPClient() *sftp.Client
- func (c *Client) StreamTransfer(r io.Reader, w io.Writer, progress ProgressCallback) error
- func (c *Client) Upload(ctx context.Context, localPath, remotePath string, progress ProgressCallback) error
- func (c *Client) UploadDirectory(ctx context.Context, localDir, remoteDir string, progress ProgressCallback) error
- func (c *Client) UploadFile(ctx context.Context, localPath, remotePath string, size int64, ...) error
- type Option
- type ProgressCallback
- type SftpCompleter
- type Shell
- type TransferConfig
Constants ¶
View Source
const ( DefaultConcurrentFiles = 5 DefaultThreadsPerFile = 64 DefaultChunkSize = 32 * 1024 // 32KB SFTP 默认包大小优化 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 包装了 sftp.Client,并持有底层的 ssh 连接引用
func (*Client) Download ¶
func (c *Client) Download(ctx context.Context, remotePath, localPath string, progress ProgressCallback) error
Download 下载入口:支持文件或目录
func (*Client) DownloadDirectory ¶
func (*Client) DownloadFile ¶
func (*Client) SFTPClient ¶
SFTPClient 返回底层的 *sftp.Client 对象, 允许调用者执行 rename, chmod, stat, symlink 等高级操作。
func (*Client) StreamTransfer ¶
StreamTransfer 简单的流式传输兜底
func (*Client) Upload ¶
func (c *Client) Upload(ctx context.Context, localPath, remotePath string, progress ProgressCallback) error
Upload 上传入口:支持文件或目录
func (*Client) UploadDirectory ¶
type Option ¶
type Option func(*Client)
Option 定义配置函数的类型
func WithChunkSize ¶
func WithConcurrentFiles ¶
func WithThreadsPerFile ¶
type ProgressCallback ¶
type ProgressCallback func(n int)
ProgressCallback 进度回调,n 为本次增量传输的字节数 此函数必须是并发安全的
type SftpCompleter ¶ added in v0.4.0
type SftpCompleter struct {
// contains filtered or unexported fields
}
SftpCompleter 实现 readline.AutoCompleter 接口 提供命令名和路径的自动补全功能
type TransferConfig ¶
type TransferConfig struct {
ConcurrentFiles int // 同时传输的文件数
ThreadsPerFile int // 单个文件的并发分块数
ChunkSize int64 // 分块大小
}
TransferConfig 定义传输配置
func DefaultConfig ¶
func DefaultConfig() TransferConfig
Click to show internal directories.
Click to hide internal directories.