Moving gateway and storage driver to packages

This commit is contained in:
Frederick F. Kautz IV
2014-11-29 14:42:22 -08:00
parent d6b65f1f04
commit 03beef3afc
9 changed files with 27 additions and 23 deletions
+22
View File
@@ -0,0 +1,22 @@
package storage
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)
}