You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
501 B
23 lines
501 B
10 years ago
|
package fsstorage
|
||
10 years ago
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
"os"
|
||
|
"path"
|
||
|
"path/filepath"
|
||
|
)
|
||
|
|
||
10 years ago
|
type FileSystemStorage struct {
|
||
10 years ago
|
RootDir string
|
||
|
}
|
||
|
|
||
10 years ago
|
func (storage FileSystemStorage) Get(objectPath string) ([]byte, error) {
|
||
10 years ago
|
return ioutil.ReadFile(path.Join(storage.RootDir, objectPath))
|
||
|
|
||
|
}
|
||
|
|
||
10 years ago
|
func (storage FileSystemStorage) Put(objectPath string, object []byte) error {
|
||
10 years ago
|
os.MkdirAll(filepath.Dir(path.Join(storage.RootDir, objectPath)), 0700)
|
||
|
return ioutil.WriteFile(path.Join(storage.RootDir, objectPath), object, 0600)
|
||
|
}
|