3 Commits

Author SHA1 Message Date
sHuXnHs c4a09cd10a tx cos support endpoint (#13) 2025-11-18 11:11:49 +08:00
jzymx50 f560f324a2 fix(huawei obs): add folder suffix (#16) 2025-11-18 11:11:06 +08:00
dependabot[bot] dd700497ef chore(deps): bump github.com/go-jose/go-jose/v4 from 4.0.4 to 4.0.5 (#14)
Bumps [github.com/go-jose/go-jose/v4](https://github.com/go-jose/go-jose) from 4.0.4 to 4.0.5.
- [Release notes](https://github.com/go-jose/go-jose/releases)
- [Commits](https://github.com/go-jose/go-jose/compare/v4.0.4...v4.0.5)

---
updated-dependencies:
- dependency-name: github.com/go-jose/go-jose/v4
  dependency-version: 4.0.5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-14 15:38:50 +08:00
7 changed files with 48 additions and 30 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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=
+4 -4
View File
@@ -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,
+34 -21
View File
@@ -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
}
+1
View File
@@ -126,6 +126,7 @@ type TencentCOS struct {
SecretID string
SecretKey string
Bucket string
Endpoint string
}
func (t *TencentCOS) Validate() error {
+5 -1
View File
@@ -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")
}