From 83c06e14dcc1e49e42a992ea6637acc600a5673e Mon Sep 17 00:00:00 2001 From: Mingcai SHEN Date: Thu, 2 Jul 2020 12:29:29 +0800 Subject: [PATCH] Updated. --- storage/filesystem.go | 6 ++++++ storage/minio.go | 6 ++++++ storage/types.go | 1 + 3 files changed, 13 insertions(+) diff --git a/storage/filesystem.go b/storage/filesystem.go index 2661afc..67ddefa 100644 --- a/storage/filesystem.go +++ b/storage/filesystem.go @@ -12,6 +12,7 @@ import ( ) type FileSystem struct { + cdn string root string prefix string minFreeSize int64 @@ -35,6 +36,7 @@ func NewFileSystem(cfg config.Config) (Storage, error) { } else { fs.root = root } + fs.cdn = cfg.GetString("cdn") fs.prefix = cfg.GetString("prefix", "/") fs.minFreeSize = cfg.GetInt64("min_free_size", 10*GB) fs.allowZeroFile = cfg.GetBool("allow_zero_file", false) @@ -45,6 +47,10 @@ func NewFileSystem(cfg config.Config) (Storage, error) { return fs, nil } +func (fs FileSystem) CDN() string { + return fs.cdn +} + func (fs FileSystem) Root() string { return fs.root } diff --git a/storage/minio.go b/storage/minio.go index b6647fd..c4ecea8 100644 --- a/storage/minio.go +++ b/storage/minio.go @@ -23,6 +23,7 @@ type minioOption struct { } type Minio struct { + cdn string endpoint string secure bool bucket string @@ -70,6 +71,10 @@ func ParseMinioURL(s string) (*minioOption, error) { return &opt, nil } +func (mio Minio) CDN() string { + return mio.cdn +} + func (mio Minio) Root() string { return mio.bucket } @@ -147,6 +152,7 @@ func NewMinio(cfg config.Config) (Storage, error) { } else { mio.prefix = s } + mio.cdn = cfg.GetString("cdn") if s3Client, e := minio.New(mio.endpoint, mio.access, mio.secret, mio.secure); e != nil { //fmt.Println("minio.New failed:", e) return nil, e diff --git a/storage/types.go b/storage/types.go index 06e71fc..173c211 100644 --- a/storage/types.go +++ b/storage/types.go @@ -27,6 +27,7 @@ type StatInfo interface { type Storage interface { //Initialize(cfg config.Config) error + CDN() string Root() string Prefix() string SaveFile(src interface{}, destination string) (FileObject, error)