Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultConfig() *config
- func DefaultGetOptions() *getOptions
- func DefaultPutOptions() *putOptions
- func DefaultSignOptions() *signOptions
- func GetReaderLength(reader io.ReadSeeker) (io.ReadSeeker, int, error)
- func Register(comp Compressor)
- type Client
- type CombinedReadCloser
- type Compressor
- type GetOptions
- type GzipCompressor
- type HeadGetObjectOutputWrapper
- type OSS
- func (ossClient *OSS) CompressAndPut(key string, reader io.ReadSeeker, meta map[string]string, ...) error
- func (ossClient *OSS) Del(key string) error
- func (ossClient *OSS) DelMulti(keys []string) error
- func (ossClient *OSS) Exists(key string) (bool, error)
- func (ossClient *OSS) Get(key string, options ...GetOptions) (string, error)
- func (ossClient *OSS) GetAndDecompress(key string) (string, error)
- func (ossClient *OSS) GetAndDecompressAsReader(key string) (io.ReadCloser, error)
- func (ossClient *OSS) GetAsReader(key string, options ...GetOptions) (io.ReadCloser, error)
- func (ossClient *OSS) GetBytes(key string, options ...GetOptions) ([]byte, error)
- func (ossClient *OSS) GetWithMeta(key string, attributes []string, options ...GetOptions) (io.ReadCloser, map[string]string, error)
- func (ossClient *OSS) Head(key string, attributes []string) (map[string]string, error)
- func (ossClient *OSS) ListObject(key string, prefix string, marker string, maxKeys int, delimiter string) ([]string, error)
- func (ossClient *OSS) Put(key string, reader io.ReadSeeker, meta map[string]string, ...) error
- func (ossClient *OSS) Range(key string, offset int64, length int64) (io.ReadCloser, error)
- func (ossClient *OSS) SignURL(key string, expired int64, options ...SignOptions) (string, error)
- type Options
- type PutOptions
- type S3
- func (a *S3) CompressAndPut(key string, reader io.ReadSeeker, meta map[string]string, ...) error
- func (a *S3) Del(key string) error
- func (a *S3) DelMulti(keys []string) error
- func (a *S3) Exists(key string) (bool, error)
- func (a *S3) Get(key string, options ...GetOptions) (string, error)
- func (a *S3) GetAndDecompress(key string) (string, error)
- func (a *S3) GetAndDecompressAsReader(key string) (io.ReadCloser, error)
- func (a *S3) GetAsReader(key string, options ...GetOptions) (io.ReadCloser, error)
- func (a *S3) GetBytes(key string, options ...GetOptions) ([]byte, error)
- func (a *S3) GetWithMeta(key string, attributes []string, options ...GetOptions) (io.ReadCloser, map[string]string, error)
- func (a *S3) Head(key string, attributes []string) (map[string]string, error)
- func (a *S3) ListObject(key string, prefix string, marker string, maxKeys int, delimiter string) ([]string, error)
- func (a *S3) Put(key string, reader io.ReadSeeker, meta map[string]string, ...) error
- func (a *S3) Range(key string, offset int64, length int64) (io.ReadCloser, error)
- func (a *S3) SignURL(key string, expired int64, options ...SignOptions) (string, error)
- type SignOptions
Constants ¶
View Source
const ( StorageTypeOSS = "oss" StorageTypeS3 = "s3" MetaCompressor = "compressor" )
View Source
const (
DefaultHttpTimeout = int64(60)
)
Variables ¶
View Source
var DefaultGzipCompressor = &GzipCompressor{}
Functions ¶
func DefaultGetOptions ¶
func DefaultGetOptions() *getOptions
func DefaultPutOptions ¶
func DefaultPutOptions() *putOptions
func DefaultSignOptions ¶ added in v3.1.7
func DefaultSignOptions() *signOptions
func GetReaderLength ¶ added in v3.1.7
func GetReaderLength(reader io.ReadSeeker) (io.ReadSeeker, int, error)
func Register ¶ added in v3.1.7
func Register(comp Compressor)
Types ¶
type Client ¶
type Client interface { Get(key string, options ...GetOptions) (string, error) GetBytes(key string, options ...GetOptions) ([]byte, error) GetAsReader(key string, options ...GetOptions) (io.ReadCloser, error) GetWithMeta(key string, attributes []string, options ...GetOptions) (io.ReadCloser, map[string]string, error) Put(key string, reader io.ReadSeeker, meta map[string]string, options ...PutOptions) error Del(key string) error DelMulti(keys []string) error Head(key string, meta []string) (map[string]string, error) ListObject(key string, prefix string, marker string, maxKeys int, delimiter string) ([]string, error) SignURL(key string, expired int64, options ...SignOptions) (string, error) GetAndDecompress(key string) (string, error) GetAndDecompressAsReader(key string) (io.ReadCloser, error) CompressAndPut(key string, reader io.ReadSeeker, meta map[string]string, options ...PutOptions) error Range(key string, offset int64, length int64) (io.ReadCloser, error) Exists(key string) (bool, error) }
Client interface
type CombinedReadCloser ¶
type CombinedReadCloser struct { ReadCloser io.ReadCloser Reader io.Reader }
CombinedReadCloser combined a ReadCloser and a Readers to a new ReaderCloser which will read from reader and close origin closer
func (CombinedReadCloser) Close ¶
func (combined CombinedReadCloser) Close() error
Close origin ReaderCloser
type Compressor ¶ added in v3.1.7
type Compressor interface { Compress(reader io.ReadSeeker) (gzipReader io.ReadSeeker, err error) ContentEncoding() string }
type GetOptions ¶
type GetOptions func(options *getOptions)
func EnableCRCValidation ¶
func EnableCRCValidation() GetOptions
func GetWithContentEncoding ¶
func GetWithContentEncoding(contentEncoding string) GetOptions
func GetWithContentType ¶
func GetWithContentType(contentType string) GetOptions
type GzipCompressor ¶ added in v3.1.7
type GzipCompressor struct { }
func (*GzipCompressor) Compress ¶ added in v3.1.7
func (g *GzipCompressor) Compress(reader io.ReadSeeker) (gzipReader io.ReadSeeker, err error)
func (*GzipCompressor) ContentEncoding ¶ added in v3.1.7
func (g *GzipCompressor) ContentEncoding() string
type HeadGetObjectOutputWrapper ¶ added in v3.1.5
type HeadGetObjectOutputWrapper struct {
// contains filtered or unexported fields
}
type OSS ¶
type OSS struct { Bucket *oss.Bucket Shards map[string]*oss.Bucket // contains filtered or unexported fields }
func (*OSS) CompressAndPut ¶
func (ossClient *OSS) CompressAndPut(key string, reader io.ReadSeeker, meta map[string]string, options ...PutOptions) error
func (*OSS) GetAndDecompressAsReader ¶
func (ossClient *OSS) GetAndDecompressAsReader(key string) (io.ReadCloser, error)
func (*OSS) GetAsReader ¶
func (ossClient *OSS) GetAsReader(key string, options ...GetOptions) (io.ReadCloser, error)
don't forget to call the close() method of the io.ReadCloser
func (*OSS) GetBytes ¶ added in v3.1.2
func (ossClient *OSS) GetBytes(key string, options ...GetOptions) ([]byte, error)
func (*OSS) GetWithMeta ¶
func (ossClient *OSS) GetWithMeta(key string, attributes []string, options ...GetOptions) (io.ReadCloser, map[string]string, error)
don't forget to call the close() method of the io.ReadCloser
func (*OSS) ListObject ¶
func (*OSS) Put ¶
func (ossClient *OSS) Put(key string, reader io.ReadSeeker, meta map[string]string, options ...PutOptions) error
type Options ¶
type Options struct { // Required, value is one of oss/s3, case insensetive StorageType string // Required AccessKeyID string // Required AccessKeySecret string // Required Endpoint string // Required Bucket string // Optional, choose which bucket to use based on the last character of the key, // if bucket is 'content', shards is ['abc', 'edf'], // then the last character of the key with a/b/c will automatically use the content-abc bucket, and vice versa Shards []string // Only for s3-like Region string // Only for s3-like, whether to force path style URLs for S3 objects. S3ForcePathStyle bool // Only for s3-like SSL bool // Only for s3-like, set http client timeout. // oss has default timeout, but s3 default timeout is 0 means no timeout. S3HttpTimeoutSecs int64 S3HttpTransportMaxConnsPerHost int S3HttpTransportIdleConnTimeout time.Duration // EnableCompressor EnableCompressor bool // CompressType gzip CompressType string // CompressLimit 大于该值之后才压缩 单位字节 CompressLimit int }
Options for New method
type PutOptions ¶
type PutOptions func(options *putOptions)
func PutWithCacheControl ¶ added in v3.1.3
func PutWithCacheControl(cacheControl string) PutOptions
func PutWithContentDisposition ¶
func PutWithContentDisposition(contentDisposition string) PutOptions
func PutWithContentEncoding ¶
func PutWithContentEncoding(contentEncoding string) PutOptions
func PutWithContentType ¶
func PutWithContentType(contentType string) PutOptions
func PutWithExpireTime ¶ added in v3.1.3
func PutWithExpireTime(expires time.Time) PutOptions
type S3 ¶
type S3 struct { ShardsBucket map[string]string BucketName string Client *s3.S3 // contains filtered or unexported fields }
func (*S3) CompressAndPut ¶
func (a *S3) CompressAndPut(key string, reader io.ReadSeeker, meta map[string]string, options ...PutOptions) error
func (*S3) GetAndDecompressAsReader ¶
func (a *S3) GetAndDecompressAsReader(key string) (io.ReadCloser, error)
func (*S3) GetAsReader ¶
func (a *S3) GetAsReader(key string, options ...GetOptions) (io.ReadCloser, error)
don't forget to call the close() method of the io.ReadCloser
func (*S3) GetBytes ¶ added in v3.1.2
func (a *S3) GetBytes(key string, options ...GetOptions) ([]byte, error)
func (*S3) GetWithMeta ¶
func (a *S3) GetWithMeta(key string, attributes []string, options ...GetOptions) (io.ReadCloser, map[string]string, error)
don't forget to call the close() method of the io.ReadCloser
func (*S3) ListObject ¶
func (*S3) Put ¶
func (a *S3) Put(key string, reader io.ReadSeeker, meta map[string]string, options ...PutOptions) error
type SignOptions ¶ added in v3.1.7
type SignOptions func(options *signOptions)
func SignWithProcess ¶ added in v3.1.7
func SignWithProcess(process string) SignOptions
Click to show internal directories.
Click to hide internal directories.