Skip to content
forked from ego-component/eos

Object storage wrapper of cloud or private storage (OSS、MinIO、S3)

License

Notifications You must be signed in to change notification settings

qingbozhang/eos

 
 

Repository files navigation

EOSS: Wrapper For Aliyun OSS And Amazon S3

awos for node: https://github.com/shimohq/awos-js

Features

  • enable shards bucket
  • add retry strategy
  • avoid 404 status code:
    • Get(objectName string) (string, error) will return "", nil when object not exist
    • Head(key string, meta []string) (map[string]string, error) will return nil, nil when object not exist

Installing

Use go get to retrieve the SDK to add it to your GOPATH workspace, or project's Go module dependencies.

go get github.com/ego-component/eos

How to use

config

[storage]
storageType = "oss" # oss|s3
accessKeyID = "xxx"
accessKeySecret = "xxx"
endpoint = "oss-cn-beijing.aliyuncs.com"
bucket = "aaa" # 定义默认storage实例
shards = []
  # 定义其他storage实例
  [storage.buckets.template] 
  bucket = "template-bucket"
  shards = []
  [storage.buckets.fileContent]
  bucket = "contents-bucket"
  shards = [
   "abcdefghijklmnopqr",
   "stuvwxyz0123456789"
  ]
import "github.com/ego-component/eos"

// 构建 os component
cmp := eoss.Load("storage").Build()

Available operations:

Get(ctx context.Context, key string, options ...GetOptions) (string, error)
GetBytes(ctx context.Context, key string, options ...GetOptions) ([]byte, error)
GetAsReader(ctx context.Context, key string, options ...GetOptions) (io.ReadCloser, error)
GetWithMeta(ctx context.Context, key string, attributes []string, options ...GetOptions) (io.ReadCloser, map[string]string, error)
Put(ctx context.Context, key string, reader io.ReadSeeker, meta map[string]string, options ...PutOptions) error
Del(ctx context.Context, key string) error
DelMulti(ctx context.Context, keys []string) error
Head(ctx context.Context, key string, meta []string) (map[string]string, error)
ListObject(ctx context.Context, key string, prefix string, marker string, maxKeys int, delimiter string) ([]string, error)
SignURL(ctx context.Context, key string, expired int64) (string, error)
GetAndDecompress(ctx context.Context, key string) (string, error)
GetAndDecompressAsReader(ctx context.Context, key string) (io.ReadCloser, error)
CompressAndPut(ctx context.Context, key string, reader io.ReadSeeker, meta map[string]string, options ...PutOptions) error
Range(ctx context.Context, key string, offset int64, length int64) (io.ReadCloser, error)
Exists(ctx context.Context, key string)(bool, error)

About

Object storage wrapper of cloud or private storage (OSS、MinIO、S3)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%