s3

package
v0.0.0-...-c73967d Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 11 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 struct {
	// contains filtered or unexported fields
}

func (*Client) Bucket

func (s *Client) Bucket() *string

func (*Client) Client

func (s *Client) Client() *s3.S3

func (*Client) Delete

func (s *Client) Delete(key string) error

func (*Client) GetDownloadURL

func (s *Client) GetDownloadURL(key string, fileName string) (string, error)

func (*Client) Read

func (s *Client) Read(key string) ([]byte, error)

func (*Client) Session

func (s *Client) Session() *session.Session

func (*Client) Upload

func (s *Client) Upload(key, fileName string, body io.Reader) error

type Interface

type Interface interface {
	//read the content, caller should close the io.ReadCloser.
	Read(key string) ([]byte, error)

	// Upload uploads a object to storage and returns object location if succeeded
	Upload(key, fileName string, body io.Reader) error

	GetDownloadURL(key string, fileName string) (string, error)

	// Delete deletes an object by its key
	Delete(key string) error
}

func NewS3Client

func NewS3Client(options *Options) (Interface, error)

type Options

type Options struct {
	Endpoint        string `json:"endpoint,omitempty" yaml:"endpoint"`
	Region          string `json:"region,omitempty" yaml:"region"`
	DisableSSL      bool   `json:"disableSSL" yaml:"disableSSL"`
	ForcePathStyle  bool   `json:"forcePathStyle" yaml:"forcePathStyle"`
	AccessKeyID     string `json:"accessKeyID,omitempty" yaml:"accessKeyID"`
	SecretAccessKey string `json:"secretAccessKey,omitempty" yaml:"secretAccessKey"`
	SessionToken    string `json:"sessionToken,omitempty" yaml:"sessionToken"`
	Bucket          string `json:"bucket,omitempty" yaml:"bucket"`
}

Options contains configuration to access a s3 service

func NewS3Options

func NewS3Options() *Options

NewS3Options creates a default disabled Options(empty endpoint)

func (*Options) AddFlags

func (s *Options) AddFlags(fs *pflag.FlagSet, c *Options)

AddFlags add options flags to command line flags, if s3-endpoint if left empty, following options will be ignored

Jump to

Keyboard shortcuts

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