storage
An application-oriented unified storage layer for Golang.
Goal
- Production ready
- High performance
- Vendor agnostic
Features
Widely services support
- azblob: Azure Blob storage
- cos: Tencent Cloud Object Storage
- dropbox: Dropbox
- fs: Local file system
- gcs: Google Cloud Storage
- kodo: qiniu kodo
- oss: Aliyun Object Storage
- qingstor: QingStor Object Storage
- s3: Amazon S3
- uss: UPYUN Storage Service
Servicer operation support
- List: list all Storager in service
- Get: get a Storager via name
- Create: create a Storager
- Delete: delete a Storager
Storager operation support
Basic operations
- Metadata: get storager metadata
- Read: read file content
- Write: write content into file
- Stat: get file's metadata
- Delete: delete a file or directory
- List: list file in prefix or dir styles
Extended operations
- Copy: copy a file inside storager
- Move: move a file inside storager
- Reach: generate a public accessible url
Multi object modes support
- Multipart: allow doing multipart uploads
- Append: allow appending to an object
- Block: allow combining an object with block ids.
- Page: allow doing random writes
Object metadata support
Common metadata
id
: unique key in servicename
: relative path towards service's work dirtype
: object type cloud befile
,dir
,link
orunknown
Optional metadata
size
: object's content size.updated-at
: object's last updated time.content-md5
: md5 digest as defined in rfc2616content-type
: media type as defined in rfc2616etag
: entity tag as defined in rfc2616storage-class
: object's storage class as defined in storage proposal
Quick Start
package main
import (
"bytes"
"log"
"github.com/aos-dev/go-storage/v3/pairs"
"github.com/aos-dev/go-service-fs/v2"
)
func main() {
// Init a service.
store, err := fs.NewStorager(pairs.WithWorkDir("/tmp"))
if err != nil {
log.Fatalf("service init failed: %v", err)
}
content := []byte("Hello, world!")
length := int64(len(content))
r := bytes.NewReader(content)
_, err = store.Write("hello", r, length)
if err != nil {
log.Fatalf("write failed: %v", err)
}
var buf bytes.Buffer
_, err = store.Read("hello", &buf)
if err != nil {
log.Fatalf("storager read: %v", err)
}
log.Printf("%s", buf.String())
}
Examples
All examples are maintained in https://github.com/aos-dev/go-storage-example.