https://github.com/ego-component/eoss
阿里oss 和 aws s3 客户端的封装
https://github.com/ego-component/eoss
aws oss s3
Last synced: 6 months ago
JSON representation
阿里oss 和 aws s3 客户端的封装
- Host: GitHub
- URL: https://github.com/ego-component/eoss
- Owner: ego-component
- License: apache-2.0
- Archived: true
- Created: 2022-11-24T05:18:53.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-10T10:28:55.000Z (over 2 years ago)
- Last Synced: 2026-01-12T03:38:18.341Z (6 months ago)
- Topics: aws, oss, s3
- Language: Go
- Homepage:
- Size: 247 KB
- Stars: 2
- Watchers: 3
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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.
```bash
go get github.com/ego-component/eoss
```
## How to use
### config
```toml
[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"
]
```
```golang
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:
```golang
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)
```