Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) Config() TransferConfig
- 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) SetForce(force bool)
- 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 Shell
- type TransferConfig
Constants ¶
View Source
const ( DefaultConcurrentFiles = 5 DefaultThreadsPerFile = 64 DefaultChunkSize = 32 * 1024 DefaultResumeMinSize = 1024 * 1024 DefaultTempSuffix = ".xops-tmp" )
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)
func WithChunkSize ¶
func WithConcurrentFiles ¶
func WithNoOverwrite ¶ added in v0.6.0
func WithResume ¶ added in v0.6.0
func WithResumeMinSize ¶ added in v0.6.0
func WithThreadsPerFile ¶
type ProgressCallback ¶
type ProgressCallback func(n int64)
ProgressCallback 进度回调,n 为本次增量传输的字节数 此函数必须是并发安全的
type TransferConfig ¶
type TransferConfig struct {
ConcurrentFiles int // 同时传输的文件数
ThreadsPerFile int // 单个文件的并发分块数
ChunkSize int64 // 分块大小
EnableResume bool
ResumeMinSize int64
TempSuffix string
Force bool
NoOverwrite bool
}
TransferConfig 定义传输配置
func DefaultConfig ¶
func DefaultConfig() TransferConfig
Click to show internal directories.
Click to hide internal directories.