mrowdy / gorage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gorage

Build Status

A file IO abstraction which saves disk storage by separating file content and file meta data.

Usage

Save a file by providing a filename and its content as byte slice

savedFile, err := gorage.Save("filename.txt", []byte("the content"), nil)

Load a file by providing its ID which was generated during saving

loadedFile, err := gorage.Load(savedFile.ID)

Delete a file by providing its ID which was generated during saving

err := gorage.Delete(savedFile.ID)

File representation

type File struct {
	ID         string
	Name       string
	Hash       string
	MimeType   string
	Content    FileContent
	Size       int
	Context    interface{}
	UploadedAt time.Time
	DeletedAt  *time.Time
}

Context

You can save some custom data as context alongside a file

context = make(map[string]string)
context["foo"] = bar

savedFile, err := gorage.Save("filename.txt", []byte("the content"), context)

Context is of type interface{} and can be everything

About


Languages

Language:Go 100.0%