storage
![Join the chat](https://img.shields.io/badge/chat-online-blue?style=flat&logo=zulip)
An application-oriented unified storage layer for Golang.
Goal
- Production ready
- High performance
- Vendor agnostic
Features
Widely services support
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's metadata
- Read: read file content
- Write: write content into file
- Stat: get file's metadata
- Delete: delete a file or directory
Extended operations
- Copy: copy a file inside storager
- Move: move a file inside storager
- Reach: generate a public accessible url
Multiple list style support
- ListDir: list files and directories under a directory
- ListPrefix: list files under a prefix
Segment/Multipart support
- ListPrefixSegment: list segments under a prefix
- InitIndexSegment: initiate an index type segment
- WriteIndexSegment: write content into an index type segment
- CompleteSegment: complete a segment to create a file
- AbortSegment: abort a segment
Object metadata support
Common metadata
id
: unique key in servicename
: relative path towards service's work dirtype
: object type cloud be file
, dir
, link
or unknown
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
import (
"log"
"github.com/aos-dev/go-storage/v2"
"github.com/aos-dev/go-storage/v2/pairs"
"github.com/aos-dev/go-services-fs"
)
store, err := fs.NewStorager(pairs.WithWorkDir("/tmp"))
if err != nil {
log.Fatalf("service init failed: %v", err)
}
var buf bytes.Buffer
n, err := store.Read("path/to/file", &buf)
if err != nil {
log.Printf("storager read: %v", err)
}