sftp

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSFTPProvider

func NewSFTPProvider(config *Config) (Provider, error)

NewSFTPProvider creates a new SFTP storage provider Example configuration:

Provider: "sftp"
Endpoint: "192.168.1.100" or "example.com"
SSHPort: 22
SSHUser: "username"
SSHPassword: "password"  // Or use SSHPrivateKey
BasePath: "/data/storage"

Types

type SFTPProvider

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

SFTPProvider implements the Provider interface for SFTP (SSH File Transfer Protocol) storage

func (*SFTPProvider) BucketExists

func (p *SFTPProvider) BucketExists(ctx context.Context, bucketName string) (bool, error)

BucketExists checks if a bucket (directory) exists

func (*SFTPProvider) Close

func (p *SFTPProvider) Close() error

Close closes the SFTP and SSH connections

func (*SFTPProvider) CopyObject

func (p *SFTPProvider) CopyObject(ctx context.Context, srcBucket, srcObject, dstBucket, dstObject string) (ObjectInfo, error)

CopyObject copies an object from source to destination

func (*SFTPProvider) CreateBucket

func (p *SFTPProvider) CreateBucket(ctx context.Context, bucketName string) error

CreateBucket creates a new bucket (directory)

func (*SFTPProvider) GetObject

func (p *SFTPProvider) GetObject(ctx context.Context, bucketName, objectName string, opts GetObjectOptions) (io.ReadCloser, ObjectInfo, error)

GetObject downloads an object from a bucket

func (*SFTPProvider) ListBuckets

func (p *SFTPProvider) ListBuckets(ctx context.Context) ([]BucketInfo, error)

ListBuckets lists all buckets (directories)

func (*SFTPProvider) ListObjects

func (p *SFTPProvider) ListObjects(ctx context.Context, bucketName, prefix string, recursive bool) <-chan ObjectInfo

ListObjects lists objects in a bucket

func (*SFTPProvider) PresignedGetObject

func (p *SFTPProvider) PresignedGetObject(ctx context.Context, bucketName, objectName string, expires time.Duration) (string, error)

PresignedGetObject generates a presigned URL for GET operation For SFTP, presigned URLs are not applicable Returns the SFTP path in the format: sftp://user@host/path

func (*SFTPProvider) PresignedPutObject

func (p *SFTPProvider) PresignedPutObject(ctx context.Context, bucketName, objectName string, expires time.Duration) (string, error)

PresignedPutObject generates a presigned URL for PUT operation For SFTP, presigned URLs are not applicable Returns the SFTP path in the format: sftp://user@host/path

func (*SFTPProvider) PutObject

func (p *SFTPProvider) PutObject(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64, opts PutObjectOptions) (ObjectInfo, error)

PutObject uploads an object to a bucket

func (*SFTPProvider) RemoveBucket

func (p *SFTPProvider) RemoveBucket(ctx context.Context, bucketName string) error

RemoveBucket removes a bucket (directory)

func (*SFTPProvider) RemoveObject

func (p *SFTPProvider) RemoveObject(ctx context.Context, bucketName, objectName string) error

RemoveObject removes an object from a bucket

func (*SFTPProvider) RemoveObjects

func (p *SFTPProvider) RemoveObjects(ctx context.Context, bucketName string, objectNames []string) <-chan RemoveObjectError

RemoveObjects removes multiple objects from a bucket

func (*SFTPProvider) StatObject

func (p *SFTPProvider) StatObject(ctx context.Context, bucketName, objectName string) (ObjectInfo, error)

StatObject gets object metadata

Jump to

Keyboard shortcuts

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