s3

package
v0.0.0-...-04f3e75 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Upload(ctx context.Context, key string, r io.Reader) (string, error)
	Download(ctx context.Context, key string, w io.WriterAt) (int64, error)
	ListObjects(ctx context.Context, opts ListOptions) (*ListOutput, error)
}

type ClientImpl

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

func NewClient

func NewClient(opts ClientOpts) (*ClientImpl, error)

NewClient creates a new SFTP client

func (*ClientImpl) Download

func (c *ClientImpl) Download(ctx context.Context, key string, w io.WriterAt) (int64, error)

func (*ClientImpl) ListObjects

func (c *ClientImpl) ListObjects(ctx context.Context, opts ListOptions) (*ListOutput, error)

func (*ClientImpl) Upload

func (c *ClientImpl) Upload(ctx context.Context, key string, r io.Reader) (string, error)

type ClientOpts

type ClientOpts struct {
	// Endpoint Optional hostname or URI for the S3 service
	Endpoint string
	// Region of the S3 service
	Region string
	// Bucket name where the files are read/written to
	Bucket string
	// AccessKey credential for the S3 service
	AccessKey string
	// SecretKey credential for the S3 service
	SecretKey string
	// ForcePathStyle set to `true` to force the request to use path-style addressing
	ForcePathStyle bool
}

type ListItem

type ListItem struct {
	// Key is the name of the object
	Key string
	// Size in bytes of the object
	Size int64
}

type ListOptions

type ListOptions struct {
	// Prefix limits the response to keys that starts with the specified prefix
	Prefix string
	// Set the maximum number of keys to be returned. By default, the action
	// returns up to 1000 keys but never more
	MaxKeys int64
	// ContinuationToken is used to continue the list operation in the bucket
	ContinuationToken string
}

type ListOutput

type ListOutput struct {
	// Items Metadata about each object returned
	Items []ListItem
	// IsTruncated indicates if there are more results to be returned
	IsTruncated bool
	// ContinuationToken is set when IsTruncated is true
	ContinuationToken string
}

type MemoryClient

type MemoryClient struct {
	Files map[string][]byte
}

func NewMemoryClient

func NewMemoryClient() *MemoryClient

func (MemoryClient) Download

func (m MemoryClient) Download(_ context.Context, key string, w io.WriterAt) (int64, error)

func (MemoryClient) ListObjects

func (m MemoryClient) ListObjects(_ context.Context, _ ListOptions) (*ListOutput, error)

func (MemoryClient) Upload

func (m MemoryClient) Upload(_ context.Context, key string, r io.Reader) (string, error)

Jump to

Keyboard shortcuts

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