feat: support custom storage path in filename

This commit is contained in:
krau
2025-02-12 12:24:11 +08:00
parent 930e838b2e
commit 0fb5634874
3 changed files with 19 additions and 4 deletions

View File

@@ -21,5 +21,13 @@ func (l *Local) Init() {
}
func (l *Local) Save(ctx context.Context, filePath, storagePath string) error {
return fileutil.CopyFile(filePath, filepath.Join(config.Cfg.Storage.Local.BasePath, storagePath))
storagePath = filepath.Join(config.Cfg.Storage.Local.BasePath, storagePath)
absPath, err := filepath.Abs(storagePath)
if err != nil {
return err
}
if err := fileutil.CreateDir(filepath.Dir(absPath)); err != nil {
return err
}
return fileutil.CopyFile(filePath, storagePath)
}