remotefile

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyStream

func CopyStream(ctx context.Context, destination io.Writer, source io.Reader, size int64, progress func(int64) error) (int64, string, error)

func ExplicitSFTPRejection added in v0.16.0

func ExplicitSFTPRejection(err error) bool

ExplicitSFTPRejection reports whether err is a definitive SFTP server status indicating the target operation was rejected without mutating the path.

func IsPermissionDenied added in v0.16.0

func IsPermissionDenied(err error) bool

IsPermissionDenied reports whether err is an OS or SFTP permission-denied status.

func IsRootPath added in v0.16.0

func IsRootPath(cleaned string) bool

IsRootPath reports whether p represents a POSIX or Windows drive root directory.

func NormalizeSFTPPath added in v0.16.0

func NormalizeSFTPPath(p string) string

NormalizeSFTPPath converts Windows drive paths (C:\..., c:/..., /C:\...) into OpenSSH SFTP canonical form (/C:/...) with an uppercase drive letter and forward slashes. Non-drive POSIX paths are cleaned without altering backslashes.

Types

type Client

type Client interface {
	Do(context.Context, func(*pkgsftp.Client) error) error
	CreatePrivateExclusive(context.Context, string, func(io.Writer) error) (bool, bool, error)
	Close() error
}

Client is the existing SFTP capability used by the streaming adapter.

type CommitResult

type CommitResult struct {
	Attempted bool
	Committed bool
	Rejected  bool
}

type Metadata

type Metadata struct {
	Path    string
	Size    int64
	ModTime int64
}

type Remote

type Remote interface {
	Inspect(context.Context, string, bool, bool) (Metadata, error)
	Upload(context.Context, string, io.Reader, int64, func() error, func(int64) error) (StreamResult, error)
	Download(context.Context, Metadata, io.Writer, func(int64) error) (StreamResult, error)
	Commit(context.Context, string, string, bool) (CommitResult, error)
	Remove(context.Context, string) error
	Close() error
}

Remote owns a dedicated SFTP subsystem. Readers/writers supplied by HTTP must have rolling deadlines and cancellation-driven I/O interruption.

type Session

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

func New

func New(client Client) *Session

func (*Session) Close

func (r *Session) Close() error

func (*Session) Commit

func (r *Session) Commit(ctx context.Context, temporary, destination string, overwrite bool) (result CommitResult, retErr error)

func (*Session) Download

func (r *Session) Download(ctx context.Context, expected Metadata, destination io.Writer, progress func(int64) error) (result StreamResult, retErr error)

func (*Session) Inspect

func (r *Session) Inspect(ctx context.Context, name string, upload, overwrite bool) (metadata Metadata, retErr error)

func (*Session) Remove

func (r *Session) Remove(ctx context.Context, name string) error

func (*Session) Upload

func (r *Session) Upload(ctx context.Context, temporary string, source io.Reader, size int64, confirm func() error, progress func(int64) error) (result StreamResult, retErr error)

type StreamResult

type StreamResult struct {
	Created           bool
	CreationAttempted bool
	CreationRejected  bool
	Bytes             int64
	SHA256            string
}

Jump to

Keyboard shortcuts

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