protocol

package
v0.0.0-...-7253c84 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MIT Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Init    = FileTransferStatus("INIT")
	NotSent = FileTransferStatus("NOT_SENT")
	Sent    = FileTransferStatus("SENT")
	Failed  = FileTransferStatus("FAILED")
)

Variables

This section is empty.

Functions

func FileExists

func FileExists(filePath string) bool

func IsSameFileSize

func IsSameFileSize(targetFile string, compareFile fs.FileInfo) (bool, error)

func ReadMetadata

func ReadMetadata(folderPath, filename string) (map[string]FileMetadata, error)

func WriteMetadata

func WriteMetadata(filePath, filename string, size uint64, status FileTransferStatus) error

Types

type ConnectionInfo

type ConnectionInfo struct {
	IP       string
	Port     int
	Username string
	Password string
}

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type File

type File struct {
	Name       string `json:"name"`
	Path       string `json:"path"`
	IsDir      bool   `json:"isdir"`
	Additional struct {
		Size uint64 `json:"size"`
	} `json:"additional"`
	List *FileListResponse
}

type FileListResponse

type FileListResponse struct {
	Data struct {
		Files  []*File `json:"files"`
		Offset int     `json:"offset"`
		Total  int     `json:"total"`
	} `json:"data"`
	Success bool `json:"success"`
}

type FileMetadata

type FileMetadata struct {
	Size   uint64 `yaml:"size"`
	Status string `yaml:"status"`
}

type FileTransferStatus

type FileTransferStatus string

type SFTPClient

type SFTPClient struct {
	ConnInfo *ConnectionInfo
	Client   *sftp.Client
}

func NewSFTPClient

func NewSFTPClient(info *ConnectionInfo) (*SFTPClient, error)

func (*SFTPClient) Close

func (sc *SFTPClient) Close() error

func (*SFTPClient) RemoveFile

func (sc *SFTPClient) RemoveFile(targetFilePath string) error

func (*SFTPClient) SendFile

func (sc *SFTPClient) SendFile(localFilePath, remoteFilePath string) (int, error)

type SynologyClient

type SynologyClient struct {
	ConnInfo *ConnectionInfo
	SessID   string
}

func NewSynologyClient

func NewSynologyClient(info *ConnectionInfo) (*SynologyClient, error)

func (*SynologyClient) DownloadFile

func (client *SynologyClient) DownloadFile(filePath, destPath string) (string, int64, error)

func (*SynologyClient) GetFileList

func (client *SynologyClient) GetFileList(folderPath string) (*FileListResponse, error)

Jump to

Keyboard shortcuts

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