mirror of
https://github.com/pgsty/minio.git
synced 2026-07-23 06:00:24 +03:00
Adding simple file storage driver for persistent storage
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user