mirror of
https://github.com/langgenius/dify-cloud-kit.git
synced 2026-07-25 21:45:26 -04:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c4a09cd10a | |||
| f560f324a2 | |||
| dd700497ef |
@@ -48,7 +48,7 @@ func main() {
|
||||
| Azure Blob | `oss/azureblob/blob.go` | `AccountName`, `AccountKey`, `Container` |
|
||||
| Google GCS | `oss/gcsblob/gcs.go` | `CredentialsJSON`, `Bucket` |
|
||||
| Tencent COS | `oss/tencentcos/cos.go` | `SecretId`, `SecretKey`, `Bucket`, `Region` |
|
||||
| Huawei OBS | `oss/huanweiobs/obs.go` | `AK`, `SK`, `Endpoint`, `Bucket` |
|
||||
| Huawei OBS | `oss/huaweiobs/obs.go` | `AK`, `SK`, `Endpoint`, `Bucket` |
|
||||
| Volcengine TOS | `oss/volcenginetos/tos.go` | `Endpoint`, `AccessKey`, `SecretKey`, `Bucket` |
|
||||
|
||||
## 🏗️ Usage with Factory
|
||||
|
||||
@@ -51,7 +51,7 @@ require (
|
||||
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
|
||||
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.0.4 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/google/go-querystring v1.0.0 // indirect
|
||||
|
||||
@@ -99,8 +99,8 @@ github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfU
|
||||
github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/go-jose/go-jose/v4 v4.0.4 h1:VsjPI33J0SB9vQM6PLmNjoHqMQNGPiZ0rHL7Ni7Q6/E=
|
||||
github.com/go-jose/go-jose/v4 v4.0.4/go.mod h1:NKb5HO1EZccyMpiZNbdUw/14tiXNyUJh188dfnMCAfc=
|
||||
github.com/go-jose/go-jose/v4 v4.0.5 h1:M6T8+mKZl/+fNNuFHvGIzDz7BTLQPIounk/b9dw3AaE=
|
||||
github.com/go-jose/go-jose/v4 v4.0.5/go.mod h1:s3P1lRrkT8igV8D9OjyL4WRyHvjB6a4JSllnOrmmBOA=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/langgenius/dify-cloud-kit/oss/aliyun"
|
||||
"github.com/langgenius/dify-cloud-kit/oss/azureblob"
|
||||
"github.com/langgenius/dify-cloud-kit/oss/gcsblob"
|
||||
"github.com/langgenius/dify-cloud-kit/oss/huanweiobs"
|
||||
"github.com/langgenius/dify-cloud-kit/oss/huaweiobs"
|
||||
"github.com/langgenius/dify-cloud-kit/oss/local"
|
||||
"github.com/langgenius/dify-cloud-kit/oss/s3"
|
||||
"github.com/langgenius/dify-cloud-kit/oss/tencentcos"
|
||||
@@ -38,9 +38,9 @@ var OSSFactory = map[string]func(oss.OSSArgs) (oss.OSS, error){
|
||||
"google-storage": gcsblob.NewGoogleCloudStorage,
|
||||
"google_storage": gcsblob.NewGoogleCloudStorage,
|
||||
|
||||
"huawei": huanweiobs.NewHuaweiOBSStorage,
|
||||
"huawei-obs": huanweiobs.NewHuaweiOBSStorage,
|
||||
"huawei_obs": huanweiobs.NewHuaweiOBSStorage,
|
||||
"huawei": huaweiobs.NewHuaweiOBSStorage,
|
||||
"huawei-obs": huaweiobs.NewHuaweiOBSStorage,
|
||||
"huawei_obs": huaweiobs.NewHuaweiOBSStorage,
|
||||
|
||||
"volcengine": volcenginetos.NewVolcengineTOSStorage,
|
||||
"volcengine_tos": volcenginetos.NewVolcengineTOSStorage,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package huanweiobs
|
||||
package huaweiobs
|
||||
|
||||
import (
|
||||
"io"
|
||||
@@ -115,30 +115,43 @@ func (h *HuaweiOBSStorage) State(key string) (oss.OSSState, error) {
|
||||
}
|
||||
|
||||
func (h *HuaweiOBSStorage) List(prefix string) ([]oss.OSSPath, error) {
|
||||
output, err := h.client.ListObjects(&obs.ListObjectsInput{
|
||||
Bucket: h.bucket,
|
||||
ListObjsInput: obs.ListObjsInput{
|
||||
Prefix: prefix,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if !strings.HasSuffix(prefix, "/") {
|
||||
prefix = prefix + "/"
|
||||
}
|
||||
paths := []oss.OSSPath{}
|
||||
for _, v := range output.Contents {
|
||||
key := strings.TrimPrefix(v.Key, prefix)
|
||||
key = strings.TrimPrefix(key, "/")
|
||||
|
||||
if key == "" {
|
||||
continue
|
||||
}
|
||||
paths = append(paths, oss.OSSPath{
|
||||
Path: key,
|
||||
IsDir: func() bool {
|
||||
return strings.HasSuffix(v.Key, "/")
|
||||
}(),
|
||||
marker := ""
|
||||
paths := []oss.OSSPath{}
|
||||
for {
|
||||
output, err := h.client.ListObjects(&obs.ListObjectsInput{
|
||||
Bucket: h.bucket,
|
||||
ListObjsInput: obs.ListObjsInput{
|
||||
Prefix: prefix,
|
||||
},
|
||||
Marker: marker,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, v := range output.Contents {
|
||||
key := strings.TrimPrefix(v.Key, prefix)
|
||||
key = strings.TrimPrefix(key, "/")
|
||||
|
||||
if key == "" {
|
||||
continue
|
||||
}
|
||||
paths = append(paths, oss.OSSPath{
|
||||
Path: key,
|
||||
IsDir: false,
|
||||
})
|
||||
}
|
||||
if output.IsTruncated {
|
||||
marker = output.NextMarker
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return paths, nil
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ type TencentCOS struct {
|
||||
SecretID string
|
||||
SecretKey string
|
||||
Bucket string
|
||||
Endpoint string
|
||||
}
|
||||
|
||||
func (t *TencentCOS) Validate() error {
|
||||
|
||||
@@ -33,7 +33,11 @@ func NewTencentCOSStorage(args oss.OSSArgs) (oss.OSS, error) {
|
||||
region := args.TencentCOS.Region
|
||||
secretID := args.TencentCOS.SecretID
|
||||
secretKey := args.TencentCOS.SecretKey
|
||||
u, err := url.Parse("https://" + bucket + ".cos." + region + ".myqcloud.com")
|
||||
endpoint := args.TencentCOS.Endpoint
|
||||
if endpoint == "" {
|
||||
endpoint = "https://" + bucket + ".cos." + region + ".myqcloud.com"
|
||||
}
|
||||
u, err := url.Parse(endpoint)
|
||||
if err != nil {
|
||||
return nil, oss.ErrProviderInit.WithError(err).WithDetail("url parse failed")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user