sftpx

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package sftpx

@author: xwc1125

Package sftpx

@author: xwc1125

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	Name    string `json:"name"`    // 文件名称
	Path    string `json:"path"`    // 路径
	Size    int64  `json:"size"`    // 文件大小
	Mode    string `json:"mode"`    // 权限
	ModTime string `json:"modTime"` // 修改时间
	IsDir   bool   `json:"isDir"`   // 是否是文件夹
}

FileInfo 文件信息

type FileInfos

type FileInfos struct {
	List []FileInfo `json:"list"`
	Dir  string     `json:"dir"`
}

FileInfos 文件对象

type Mode

type Mode int
const (
	Mode_ReadDir  Mode = iota + 1 // 读取列表
	Mode_Mkdir                    // 创建文件夹
	Mode_Rename                   // 修改名称
	Mode_Remove                   // 删除
	Mode_Download                 // 下载
	Mode_Upload                   // 上传
)

type OptParams

type OptParams struct {
	Mode     Mode           `json:"mode"`                // 操作类型
	Path     string         `json:"path,omitempty"`      // 路径
	IsDir    bool           `json:"is_dir,omitempty"`    // 路径是否为文件夹
	OldName  string         `json:"old_name"`            // 旧文件名
	NewName  string         `json:"new_name"`            // 新文件名
	FileName string         `json:"file_name,omitempty"` // 文件上传时的文件名
	File     multipart.File `json:"file,omitempty"`      // 文件上传时的文件内容
}

type SFTP

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

SFTP sftp对象

func NewSFTP

func NewSFTP(rootCtx context.Context, client *ssh.Client) (*SFTP, error)

NewSFTP 创建sftp

func (*SFTP) Close

func (s *SFTP) Close() error

Close 关闭

func (*SFTP) DownloadDir

func (s *SFTP) DownloadDir(fullPath string) ([]byte, error)

DownloadDir 下载文件/夹

func (*SFTP) DownloadFile

func (s *SFTP) DownloadFile(fullPath string) ([]byte, error)

DownloadFile 下载文件

func (*SFTP) HandleOpt

func (s *SFTP) HandleOpt(params OptParams) (interface{}, error)

func (*SFTP) Mkdir

func (s *SFTP) Mkdir(dirPath string) error

Mkdir 创建文件夹

func (*SFTP) ReadDir

func (s *SFTP) ReadDir(dirPath string) (*FileInfos, error)

ReadDir 读取文件夹

func (*SFTP) Remove

func (s *SFTP) Remove(fullPath string, isDir bool) error

Remove 删除

func (*SFTP) Rename

func (s *SFTP) Rename(o, n string) error

Rename 重命名

func (*SFTP) ServeWs

func (s *SFTP) ServeWs(wsConn *websocket.Conn) error

func (*SFTP) SftpClient

func (s *SFTP) SftpClient() *sftp.Client

func (*SFTP) Upload

func (s *SFTP) Upload(desDir string, fileName string, srcFile multipart.File) error

Upload 上传

type SftpApi

type SftpApi struct {
}

func (SftpApi) SftpDownloadDir

func (ap SftpApi) SftpDownloadDir(c contextx.Context, sshClient *ssh.Client)

SftpDownloadDir 下载文件夹

func (SftpApi) SftpDownloadFile

func (ap SftpApi) SftpDownloadFile(c contextx.Context, sshClient *ssh.Client)

SftpDownloadFile 下载文件

func (SftpApi) SftpFileInfos

func (ap SftpApi) SftpFileInfos(c contextx.Context, sshClient *ssh.Client)

SftpFileInfos 文件夹列表

func (SftpApi) SftpMkdir

func (ap SftpApi) SftpMkdir(c contextx.Context, sshClient *ssh.Client)

SftpMkdir 创建文件

func (SftpApi) SftpRm

func (ap SftpApi) SftpRm(c contextx.Context, sshClient *ssh.Client)

SftpRm 删除文件夹

func (SftpApi) SftpUpload

func (ap SftpApi) SftpUpload(c contextx.Context, sshClient *ssh.Client)

SftpUpload 上传文件

Jump to

Keyboard shortcuts

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