-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patch🚑: dev merge
- Loading branch information
Showing
19 changed files
with
364 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,45 @@ | ||
package file_store | ||
|
||
type FileStore struct { | ||
import "fmt" | ||
|
||
type OXS struct { | ||
// Endpoint 访问域名 | ||
Endpoint string | ||
// AccessKeyID AK | ||
AccessKeyID string | ||
// AccessKeySecret AKS | ||
AccessKeySecret string | ||
// BucketName 桶名称 | ||
BucketName string | ||
} | ||
|
||
// Setup 配置数据库 | ||
func (e *FileStore) Setup(driver string) { | ||
//fileStoreType := driver | ||
//if fileStoreType == "ALiYunOSS" { | ||
// var store = new(ALiYunOSS) | ||
// store.Setup() | ||
//} | ||
// Setup 配置文件存储driver | ||
func (e *OXS) Setup(driver DriverType, options ...ClientOption) FileStoreType { | ||
fileStoreType := driver | ||
var fileStore FileStoreType | ||
switch fileStoreType { | ||
case AliYunOSS: | ||
fileStore = new(ALiYunOSS) | ||
err := fileStore.Setup(e.Endpoint, e.AccessKeyID, e.AccessKeySecret, e.BucketName) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
return fileStore | ||
case HuaweiOBS: | ||
fileStore = new(HuaWeiOBS) | ||
err := fileStore.Setup(e.Endpoint, e.AccessKeyID, e.AccessKeySecret, e.BucketName) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
return fileStore | ||
case QiNiuKodo: | ||
fileStore = new(QiNiuKODO) | ||
err := fileStore.Setup(e.Endpoint, e.AccessKeyID, e.AccessKeySecret, e.BucketName) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
return fileStore | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
package file_store | ||
|
||
// DriverType 驱动类型 | ||
type DriverType string | ||
|
||
const ( | ||
// HuaweiOBS 华为云OBS | ||
HuaweiOBS DriverType = "HuaweiOBS" | ||
// AliYunOSS 阿里云OSS | ||
AliYunOSS DriverType = "AliYunOSS" | ||
// QiNiuKodo 七牛云kodo | ||
QiNiuKodo DriverType = "QiNiuKodo" | ||
) | ||
|
||
type ClientOption map[string]interface{} | ||
|
||
// TODO: FileStoreType名称待定 | ||
|
||
// FileStoreType OXS | ||
type FileStoreType interface { | ||
Setup() error | ||
UpLoad(yourObjectName string, localFile string) error | ||
// Setup 装载 endpoint sss | ||
Setup(endpoint, accessKeyID, accessKeySecret, BucketName string, options ...ClientOption) error | ||
// UpLoad 上传 | ||
UpLoad(yourObjectName string, localFile interface{}) error | ||
// GetTempToken 获取临时Token | ||
GetTempToken() (string, error) | ||
} |
Oops, something went wrong.