storage

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFTPProtocolClientInvalid = errors.New("protocol: client invalid, expected FTP")
View Source
var ErrFileOrObjectCannotFinalize = errors.New("file or object cannot finalize, please retry")
View Source
var ErrLocalProtocolIOInvalid = errors.New("protocol: local IO invalid, expected local")
View Source
var ErrS3ProtocolClientInvalid = errors.New("protocol: client invalid, expected S3")
View Source
var ErrSFTPProtocolClientInvalid = errors.New("protocol: client invalid, expected SFTP")

Functions

This section is empty.

Types

type Destination

type Destination interface {
	// GetFileInfo fetches a file from the storage.
	//
	// Parameters:
	//  - ctx: the context of the request
	//  - filePath: the path of the file you want to fetch
	//  - client: the client used to fetch the file
	//
	// Returns:
	//  - reader: the reader that contains the content of the file
	//  - info: the information of the file
	//  - err: the error if any occurred, nil otherwise
	GetFileInfo(ctx context.Context, filePath string, client protoc.Client) (info xferfile.Info, err error)

	// CreateFile creates a file at the specified path
	//
	// Parameters:
	//  - ctx: the context of the request
	//  - path: the path of the file you want to create
	//  - size: the size of the file in bytes
	//  - modTime: the modification time of the source file
	//  - client: the client used to create the file
	//
	// Returns:
	//  - err: the error if any occurred, nil otherwise
	CreateFile(ctx context.Context, path string, size int64, modTime time.Time, client protoc.Client) (err error)

	// TransferFileChunk writes a chunk of data to the file from the reader
	//
	// Parameters:
	//  - ctx: the context of the request
	//  - filePath: the path of the file you want to write to
	//  - reader: the reader that contains the content of the file
	//  - offset: the offset in bytes (zero-based), indicating the position of the last byte written
	//  - client: the client used to write the file
	//
	// Returns:
	//  - n: the number of bytes written
	//  - err: the error if any occurred, nil otherwise
	TransferFileChunk(ctx context.Context, filePath string, reader io.Reader, offset int64, client protoc.Client) (n int64, err error)

	// FinalizeTransfer finalizes the file at the specified path (make the transfer complete)
	//
	// Parameters:
	//  - ctx: the context of the request
	//  - filePath: the path of the file you want to finalize
	//  - client: the client used to finalize the file
	//
	// Returns:
	//  - err: the error if any occurred, nil otherwise
	FinalizeTransfer(ctx context.Context, filePath string, client protoc.Client) (err error)

	// DeleteFile deletes the file at the specified path
	//
	// Parameters:
	//  - ctx: the context of the request
	//  - filePath: the path of the file you want to delete
	//  - client: the client used to delete the file
	//
	// Returns:
	//  - err: the error if any occurred, nil otherwise
	DeleteFile(ctx context.Context, filePath string, client protoc.Client) (err error)

	// Close closes the destination
	Close()
}

type Source

type Source interface {
	// GetFileInfo retrieves the size of the file at the given path
	//
	// Parameters:
	//  - ctx: the context of the request
	//  - filePath: the path of the file
	//  - client: the client used to fetch the file
	//
	// Returns:
	//  - size: the size of the file
	//  - err: the error if any occurred, nil otherwise
	GetFileInfo(ctx context.Context, filePath string, client protoc.Client) (info xferfile.Info, err error)

	// GetFileFromOffset fetches a file from the storage via
	// the protocol client. This is useful when the file is stored
	// in a remote server like FTP, SFTP, S3, etc.
	//
	// Parameters:
	//  - ctx: the context of the request
	//  - filePath: the path of the file you want to fetch
	//  - offset: the offset of the file you want to fetch
	//  - client: the client used to fetch the file
	//
	// Returns:
	//  - reader: the reader that contains the content of the file
	//  - err: the error if any occurred, nil otherwise
	GetFileFromOffset(ctx context.Context, filePath string, offset int64, client protoc.Client) (reader io.ReadCloser, err error)

	// Close closes the source
	Close()
}

Directories

Path Synopsis
Package mock_storage is a generated GoMock package.
Package mock_storage is a generated GoMock package.
Package s3 provides a storage backend using AWS S3 or compatible servers.
Package s3 provides a storage backend using AWS S3 or compatible servers.

Jump to

Keyboard shortcuts

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