goftp

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: BSD-2-Clause Imports: 10 Imported by: 0

README

FTP连接 支持FTP和SFTP两种方式

Documentation

Index

Constants

View Source
const (
	DataSize = 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type EntryHandler

type EntryHandler func(e *ftp.Entry, currentPath string) error

EntryHandler 遍历ftp目录时的文件handler

type FileSource

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

FTP 文件对象

type FtpClient

type FtpClient struct {
	Protocol string
	Ftp      *ftp.ServerConn
	Ssh      *ssh.Client
	Sftp     *sftp.Client
	// contains filtered or unexported fields
}

func NewFtpClient

func NewFtpClient() *FtpClient

func (*FtpClient) Download

func (this *FtpClient) Download(local, remote, file string) error

文件下载

func (*FtpClient) Finish

func (this *FtpClient) Finish() error

func (*FtpClient) GetFile

func (this *FtpClient) GetFile(path string) ([]string, error)

获取文件列表

func (*FtpClient) Handler

func (this *FtpClient) Handler(e *ftp.Entry, currentPath string) error

函调函数

func (*FtpClient) HandlerUpload

func (this *FtpClient) HandlerUpload(e *ftp.Entry, currentPath string) error

函调函数-上传

func (*FtpClient) Init

func (this *FtpClient) Init(protocol, ip, port, user, pass string) error

func (*FtpClient) Rename

func (this *FtpClient) Rename(tmp, dst, file string) error

func (*FtpClient) Upload

func (this *FtpClient) Upload(local, remote, file string) error

func (*FtpClient) Walk

func (this *FtpClient) Walk(rootDir string) error

M1: 遍历ftp目录,获取文件

type FtpFile

type FtpFile struct {
	FileName string //FTP文件名
	Path     string //FTP文件的全路径+文件名
	Type     int    //FTP文件类型,文件:0, 文件夹:1
	Size     int    //FTP文件大小
}

FTP文件信息

type Server

type Server struct {
	Protocol   string `json:"Protocol"`
	IP         string `json:"IP"`
	Port       string `json:"Port"`
	UserName   string `json:"UserName"`
	PassWord   string `json:"PassWord"`
	RemotePath string `json:"RemotePath"` // 远程临时目录(上传用)
	TargetPath string `json:"TargetPath"` // 远程目标目录(上传用,下载时为目标目录)
	RmtTmpPath string `json:"RmtTmpPath"` // 远程临时目录(上传用,向下兼容)
	BackupPath string `json:"BackupPath"` // 备份目录(上传后将本地文件转移到的目标目录,下载后将远程文件转移到的目标目录)
	LocalPath  string `json:"LocalPath"`  // 本地目标目录(下载为目标目录,上传为源目录)
	TempPath   string `json:"TempPath"`   // 本地临时目录(下载为临时目录,上传不用)
}

Jump to

Keyboard shortcuts

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