mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-11 18:59:40 +08:00
feat: init commit
This commit is contained in:
25
storage/local/local.go
Normal file
25
storage/local/local.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/duke-git/lancet/v2/fileutil"
|
||||
"github.com/krau/SaveAny-Bot/config"
|
||||
"github.com/krau/SaveAny-Bot/logger"
|
||||
)
|
||||
|
||||
type Local struct{}
|
||||
|
||||
func (l *Local) Init() {
|
||||
err := os.MkdirAll(config.Cfg.Storage.Local.BasePath, os.ModePerm)
|
||||
if err != nil {
|
||||
logger.L.Fatalf("Failed to create local storage directory: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Local) Save(ctx context.Context, filePath, storagePath string) error {
|
||||
return fileutil.CopyFile(filePath, filepath.Join(config.Cfg.Storage.Local.BasePath, storagePath))
|
||||
}
|
||||
Reference in New Issue
Block a user