Documentation ¶
Index ¶
- Constants
- type Client
- func (s *Client) Bucket() *string
- func (s *Client) Client() *s3.S3
- func (s *Client) Delete(key string) error
- func (s *Client) GetDownloadURL(key string, fileName string) (string, error)
- func (s *Client) Read(key string) ([]byte, error)
- func (s *Client) Session() *session.Session
- func (s *Client) Upload(key, fileName string, body io.Reader, size int) error
- type Interface
- type Options
Constants ¶
View Source
const ( DefaultPartSize = 5 * bytefmt.MEGABYTE // MinConcurrency is the minimum concurrency when uploading a part to Amazon S3, // it's also the default value of Concurrency in aws-sdk-go. MinConcurrency = 5 // MaxConcurrency is the maximum concurrency to limit the goroutines. MaxConcurrency = 128 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetDownloadURL ¶
func (*Client) Upload ¶
Upload use Multipart upload to upload a single object as a set of parts. If the data length is known to be large, it is recommended to pass in the data length, it will helps to calculate concurrency. Otherwise, `size` can be 0, use 5 as default upload concurrency, same as aws-sdk-go. See https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html for more details.
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, size int) error GetDownloadURL(key string, fileName string) (string, error) // Delete deletes an object by its key Delete(key string) error }
func NewS3Client ¶
type Options ¶
type Options struct { Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"` Region string `json:"region,omitempty" yaml:"region,omitempty"` DisableSSL bool `json:"disableSSL" yaml:"disableSSL"` ForcePathStyle bool `json:"forcePathStyle" yaml:"forcePathStyle"` AccessKeyID string `json:"accessKeyID,omitempty" yaml:"accessKeyID,omitempty"` SecretAccessKey string `json:"secretAccessKey,omitempty" yaml:"secretAccessKey,omitempty"` SessionToken string `json:"sessionToken,omitempty" yaml:"sessionToken,omitempty"` Bucket string `json:"bucket,omitempty" yaml:"bucket,omitempty"` }
Options contains configuration to access a s3 service
func NewS3Options ¶
func NewS3Options() *Options
NewS3Options creates a default disabled Options(empty endpoint)
func (*Options) AddFlags ¶
AddFlags add options flags to command line flags, if s3-endpoint if left empty, following options will be ignored
Click to show internal directories.
Click to hide internal directories.