From 79ac2644740c11bb21d7823ca9b9004dd936eb7e Mon Sep 17 00:00:00 2001 From: reshke Date: Thu, 15 Aug 2024 10:14:16 +0000 Subject: [PATCH] Mkdir all parent dirs for fs storager --- pkg/storage/filestorage.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/storage/filestorage.go b/pkg/storage/filestorage.go index b326e6e..4b4d970 100644 --- a/pkg/storage/filestorage.go +++ b/pkg/storage/filestorage.go @@ -50,7 +50,10 @@ func (s *FileStorageInteractor) ListPath(prefix string) ([]*ObjectInfo, error) { } func (s *FileStorageInteractor) PutFileToDest(name string, r io.Reader) error { - file, err := os.Create(path.Join(s.cnf.StoragePrefix, name)) + fPath := path.Join(s.cnf.StoragePrefix, name) + fDir := path.Dir(fPath) + os.MkdirAll(fDir, 0700) + file, err := os.Create(fPath) if err != nil { return err }