Categorygithub.com/ego-component/eoss
modulepackage
1.0.6
Repository: https://github.com/ego-component/eoss.git
Documentation: pkg.go.dev

# README

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/eoss

How to use

config

[storage]
storageType = "oss" # oss|s3
accessKeyID = "xxx"
accessKeySecret = "xxx"
endpoint = "oss-cn-beijing.aliyuncs.com"
bucket = "aaa"
shards = []
[storage.buckets.template] # 可配置多套buckets配置,buckets里的配置会替换上层配置
bucket = "template-bucket"
shards = []
[storage.buckets.fileContent]
bucket = "contents-bucket"
shards = [
 "abcdefghijklmnopqr",
 "stuvwxyz0123456789"
]
import "github.com/ego-component/eoss"

// 单独一个 bucket 配置
client := eoss.Load("storage").Build()
// 多 bucket 配置
client := eoss.Load("storage").Build(eoss.WithBucketKey("template"))

// 带context(可记录链路)
client.WithContext(ctx).Get(key)

Available operations:

WithContext(ctx context.Context) Component
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) (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)

# Functions

CopyWithAttributes specify metadata keys to copy.
CopyWithNewAttributes append new attributes(meta) to new object NOTE: if this option was specified, the metadata(s) of source object would be dropped expect specifying keys to copy using CopyWithAttributes() option.
No description provided by the author
DefaultConfig 返回默认配置.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author

# Structs

CombinedReadCloser combined a ReadCloser and a Readers to a new ReaderCloser which will read from reader and close origin closer.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

Component interface.
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author