2022-09-16 10:53:45 +00:00
|
|
|
package cloud_storage
|
|
|
|
|
|
|
|
import (
|
2022-10-17 08:32:31 +00:00
|
|
|
"github.com/1Panel-dev/1Panel/backend/constant"
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/utils/cloud_storage/client"
|
2022-09-16 10:53:45 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type CloudStorageClient interface {
|
|
|
|
ListBuckets() ([]interface{}, error)
|
2022-09-27 16:08:21 +00:00
|
|
|
ListObjects(prefix string) ([]interface{}, error)
|
2022-09-16 10:53:45 +00:00
|
|
|
Exist(path string) (bool, error)
|
|
|
|
Delete(path string) (bool, error)
|
|
|
|
Upload(src, target string) (bool, error)
|
|
|
|
Download(src, target string) (bool, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewCloudStorageClient(vars map[string]interface{}) (CloudStorageClient, error) {
|
|
|
|
if vars["type"] == constant.S3 {
|
|
|
|
return client.NewS3Client(vars)
|
|
|
|
}
|
|
|
|
if vars["type"] == constant.OSS {
|
|
|
|
return client.NewOssClient(vars)
|
|
|
|
}
|
|
|
|
if vars["type"] == constant.Sftp {
|
|
|
|
return client.NewSftpClient(vars)
|
|
|
|
}
|
|
|
|
if vars["type"] == constant.MinIo {
|
|
|
|
return client.NewMinIoClient(vars)
|
|
|
|
}
|
2023-04-03 10:51:11 +00:00
|
|
|
if vars["type"] == constant.Cos {
|
|
|
|
return client.NewCosClient(vars)
|
|
|
|
}
|
|
|
|
if vars["type"] == constant.Kodo {
|
|
|
|
return client.NewKodoClient(vars)
|
|
|
|
}
|
2022-09-16 10:53:45 +00:00
|
|
|
return nil, constant.ErrNotSupportType
|
|
|
|
}
|