Creating subdirectories in fs now works

This commit is contained in:
Frederick F. Kautz IV
2015-01-27 17:47:11 -08:00
parent 25ad24997e
commit 5daa408e2c
4 changed files with 52 additions and 5 deletions

View File

@@ -176,6 +176,13 @@ func (storage *storage) StoreObject(bucket string, key string, data io.Reader) e
// get object path
objectPath := path.Join(storage.root, bucket, key)
objectDir := path.Dir(objectPath)
if _, err := os.Stat(objectDir); os.IsNotExist(err) {
err = os.MkdirAll(objectDir, 0700)
if err != nil {
return mstorage.EmbedError(bucket, key, err)
}
}
// check if object exists
if _, err := os.Stat(objectPath); !os.IsNotExist(err) {