|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
package storage |
|
|
|
|
package fsstorage |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"io/ioutil" |
|
|
|
@ -7,16 +7,16 @@ import ( |
|
|
|
|
"path/filepath" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
type FileStorage struct { |
|
|
|
|
type FileSystemStorage struct { |
|
|
|
|
RootDir string |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (storage FileStorage) Get(objectPath string) ([]byte, error) { |
|
|
|
|
func (storage FileSystemStorage) Get(objectPath string) ([]byte, error) { |
|
|
|
|
return ioutil.ReadFile(path.Join(storage.RootDir, objectPath)) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (storage FileStorage) Put(objectPath string, object []byte) error { |
|
|
|
|
func (storage FileSystemStorage) 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) |
|
|
|
|
} |