A file IO abstraction which saves disk storage by separating file content and file meta data.
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)
type File struct {
ID string
Name string
Hash string
MimeType string
Content FileContent
Size int
Context interface{}
UploadedAt time.Time
DeletedAt *time.Time
}
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