sftp

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SFTP

type SFTP struct {
	Username        string
	Password        string
	Port            string
	Host            string
	HostKeyCallback ssh.HostKeyCallback
	AuthMethod      []ssh.AuthMethod
	Connected       bool
	Connection      *ssh.Client
	Client          *sftp.Client
	Timeout         time.Duration
}

SFTP sftp struct

func (*SFTP) Close

func (s *SFTP) Close()

Close close connection

func (*SFTP) Connect

func (s *SFTP) Connect() error

Connect connect to sftp server

func (*SFTP) Delete

func (s *SFTP) Delete(path string) error

Delete deletes a file

func (*SFTP) Download

func (s *SFTP) Download(remote, local string) (int64, error)

Download download a file

func (*SFTP) Exist

func (s *SFTP) Exist(path string) bool

Exist check if file is exist

func (*SFTP) ListDirectory

func (s *SFTP) ListDirectory(dir string) ([]os.FileInfo, error)

ListDirectory list directory

func (*SFTP) ListDirectoryRecursive

func (s *SFTP) ListDirectoryRecursive(dir string) ([]string, error)

ListDirectoryRecursive list directory info recursive

func (*SFTP) Stat

func (s *SFTP) Stat(path string) (os.FileInfo, error)

Stat return file info

func (*SFTP) Upload

func (s *SFTP) Upload(local, remote string, overwrite UploadAction) (int64, error)

Upload upload a local file to sftp

type UploadAction

type UploadAction int
const (
	UPLOAD_DONT_OVERWRITE UploadAction = 0
	UPLOAD_OVERWRITE      UploadAction = 1
	UPLOAD_CONTINUE       UploadAction = 2
)

Jump to

Keyboard shortcuts

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