sftp

package
v1.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(client *Client, remotePath string, localPath string, progress ProgressCallback) error

func DownloadDir

func DownloadDir(client *Client, remoteDir string, localDir string, progress ProgressCallback) error

func RemoveRemoteAll added in v1.3.0

func RemoveRemoteAll(fs RemoteRemoveFS, remotePath string) error

func Upload

func Upload(client *Client, localPath string, remotePath string, progress ProgressCallback) error

func UploadDir

func UploadDir(client *Client, localDir string, remoteDir string, progress ProgressCallback) error

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(sshClient *ssh.Client) (*Client, error)

func (*Client) Chmod

func (c *Client) Chmod(path string, mode os.FileMode) error

func (*Client) Close

func (c *Client) Close() error

func (*Client) List

func (c *Client) List(path string) ([]FileInfo, error)

func (*Client) Mkdir

func (c *Client) Mkdir(path string) error

func (*Client) Remove

func (c *Client) Remove(path string) error

func (*Client) RemoveDirectory added in v1.3.0

func (c *Client) RemoveDirectory(path string) error

func (*Client) Rename

func (c *Client) Rename(oldPath, newPath string) error

func (*Client) SFTPClient

func (c *Client) SFTPClient() *sftp.Client

func (*Client) Stat

func (c *Client) Stat(path string) (*FileInfo, error)

type FileInfo

type FileInfo struct {
	Name    string
	Size    int64
	IsDir   bool
	ModTime time.Time
	Mode    os.FileMode
}

type ProgressCallback

type ProgressCallback func(TransferProgress)

type RemoteRemoveFS added in v1.3.0

type RemoteRemoveFS interface {
	List(path string) ([]FileInfo, error)
	Remove(path string) error
	RemoveDirectory(path string) error
}

type TransferProgress

type TransferProgress struct {
	TotalBytes       int64
	TransferredBytes int64
	CurrentFile      string
	Done             bool
	FileIndex        int // 1-based index of current file in batch
	TotalFiles       int // total files in batch (0 = unknown)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址