You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
909 B
Go

7 months ago
package initialize
import (
"fmt"
"gopkg.in/yaml.v3"
"os"
"uploader/config"
"uploader/global"
"uploader/utils/storage"
)
7 months ago
func InitConfig(configFilePath string) *config.Config {
fmt.Println("configFilePath: " + configFilePath)
content, err := os.ReadFile(configFilePath)
7 months ago
if err != nil {
fmt.Printf("err: %v\n", err)
panic(err)
}
var conf config.Config
if err := yaml.Unmarshal(content, &conf); err != nil {
fmt.Printf("err: %v\n", err)
panic(err)
}
return &conf
}
func InitStorage() storage.Storage {
7 months ago
if global.Config.Storage.StorageType == "oss" {
return storage.NewOssStorage(global.Config.Storage.Oss)
} else if global.Config.Storage.StorageType == "obs" {
return storage.NewObsStorage(global.Config.Storage.Obs)
} else if global.Config.Storage.StorageType == "cos" {
return storage.NewCosStorage(global.Config.Storage.Cos)
7 months ago
} else {
panic("存储系统不存在")
}
}