Adding simple file storage driver for persistent storage

This commit is contained in:
Frederick F. Kautz IV
2014-11-14 18:22:50 -07:00
parent 2679324afe
commit 44b28166f5
6 changed files with 164 additions and 45 deletions
+22
View File
@@ -0,0 +1,22 @@
package minio
import (
"io/ioutil"
"os"
"path"
"path/filepath"
)
type FileStorage struct {
RootDir string
}
func (storage FileStorage) Get(objectPath string) ([]byte, error) {
return ioutil.ReadFile(path.Join(storage.RootDir, objectPath))
}
func (storage FileStorage) Put(objectPath string, object []byte) error {
os.MkdirAll(filepath.Dir(path.Join(storage.RootDir, objectPath)), 0700)
return ioutil.WriteFile(path.Join(storage.RootDir, objectPath), object, 0600)
}