github.com/sandwich-go/boost@v1.3.29/misc/cloud/storage_qcloud.go (about) 1 package cloud 2 3 import "fmt" 4 5 const StorageTypeQCloud StorageType = "qcloud" // 腾讯云 6 7 func init() { 8 register(StorageTypeQCloud, newQCloudStorage) 9 } 10 11 type qCloudStorage struct { 12 *baseStorage 13 } 14 15 func newQCloudStorage(accessKeyID string, secretAccessKey string, bucket string, opts ...StorageOption) (Storage, error) { 16 bb, err := newBaseBucket(accessKeyID, secretAccessKey, bucket, func(options *StorageOptions) (ep string, err error) { 17 if len(options.GetRegion()) == 0 { 18 ep = "cos.ap-beijing.myqcloud.com" 19 } else { 20 ep = fmt.Sprintf("cos.%s.myqcloud.com", options.GetRegion()) 21 } 22 return 23 }, opts...) 24 if err != nil { 25 return nil, err 26 } 27 return &qCloudStorage{baseStorage: bb}, nil 28 } 29 30 func (c qCloudStorage) GetRootUrl() string { 31 return fmt.Sprintf("https://%s.cos.%s.myqcloud.com", c.bucket, c.spec.GetRegion()) 32 }