๐Ÿ“ฆ langgenius / dify-cloud-kit

A library and tools for open cloud development in Go.

โ˜… 12 stars โ‘‚ 16 forks ๐Ÿ‘ 12 watching โš–๏ธ Apache License 2.0
๐Ÿ“ฅ Clone https://github.com/langgenius/dify-cloud-kit.git
HTTPS git clone https://github.com/langgenius/dify-cloud-kit.git
SSH git clone git@github.com:langgenius/dify-cloud-kit.git
CLI gh repo clone langgenius/dify-cloud-kit
dependabot[bot] dependabot[bot] chore(deps): bump golang.org/x/crypto from 0.37.0 to 0.45.0 (#17) d56e719 26 days ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ oss
๐Ÿ“ tests
๐Ÿ“„ go.mod
๐Ÿ“„ go.sum
๐Ÿ“„ LICENSE
๐Ÿ“„ README.md
๐Ÿ“„ README.md

Dify Cloud Kit

Dify Cloud Kit is a unified abstraction library for integrating various cloud object storage services in Go. It simplifies switching between providers and supports local testing and multi-cloud deployments.

โœจ Features

  • Supports multiple backends: Local FS, Aliyun OSS, AWS S3, Azure Blob, Tencent COS, Huawei OBS, Google GCS
  • Unified and clean interface
  • Factory pattern to dynamically load drivers
  • Easy to write tests with local and in-memory backends

๐Ÿ“ฆ Installation

go get github.com/langgenius/dify-cloud-kit

๐Ÿš€ Quick Start

import (
    "github.com/langgenius/dify-cloud-kit/oss"
    "github.com/langgenius/dify-cloud-kit/oss/factory"
)

func main() {
    store, err := factory.Load("local", oss.OSSArgs{
        Local: &oss.Local{
            Path: "/tmp/files",
        },
    })
    if err != nil {
        panic(err)
    }

    files, _ := store.List("/")
    fmt.Println(files)
}

๐Ÿ“ Supported Storage Providers

ProviderModule PathRequired Fields
Localoss/local/localfile.goPath
Aliyun OSSoss/aliyun/aliyun.goEndpoint, AccessKey, SecretKey, Bucket
AWS S3oss/s3/s3.goRegion, AccessKey, SecretKey, Bucket
Azure Bloboss/azureblob/blob.goAccountName, AccountKey, Container
Google GCSoss/gcsblob/gcs.goCredentialsJSON, Bucket
Tencent COSoss/tencentcos/cos.goSecretId, SecretKey, Bucket, Region
Huawei OBSoss/huaweiobs/obs.goAK, SK, Endpoint, Bucket
Volcengine TOSoss/volcenginetos/tos.goEndpoint, AccessKey, SecretKey, Bucket

๐Ÿ—๏ธ Usage with Factory

You can dynamically load a storage backend using the factory:

store, err := factory.Load("s3", oss.OSSArgs{
    S3: &oss.S3{
        Region:    "us-west-2",
        AccessKey: "AKIA...",
        SecretKey: "SECRET...",
        Bucket:    "my-bucket",
    },
})

๐Ÿงช Testing

Unit tests are located in tests/oss/oss_test.go.

Environment Variables

Some providers require credentials to be passed via environment variables. Set them as needed:

export OSS_AWS_ACCESS_KEY=your-access-key
export OSS_AWS_SECRET_KEY=your-secret-key
export OSS_AWS_REGION=your-region
export OSS_S3_BUCKET=test-bucket

export OSS_ALIYUN_ENDPOINT=your-endpoint
export OSS_ALIYUN_ACCESS_KEY=your-access-key
export OSS_ALIYUN_SECRET_KEY=your-secret-key
export OSS_ALIYUN_BUCKET=test-bucket

Run Tests

go test ./...

๐Ÿ“„ License

This project is licensed under the Apache 2.0 License.

NOTICE

Some parts of the code in this project originate from dify-plugin-daemon

ProviderAuthorPR
Aliyun OSSbravomarkhttps://github.com/langgenius/dify-plugin-daemon/pull/261
Azure Blobtechanhttps://github.com/langgenius/dify-plugin-daemon/pull/172
Google GCSHironori Yamamotohttps://github.com/langgenius/dify-plugin-daemon/pull/237
Locallengyhuahttps://github.com/langgenius/dify-plugin-daemon/pull/157
AWS S3Yeuolyhttps://github.com/langgenius/dify-plugin-daemon/commit/9ad9d7d4de1d123956ab07955e541bc4053e5170
Tencent COSquicksandhttps://github.com/langgenius/dify-plugin-daemon/pull/97
Volcengine TOSquicksandhttps://github.com/langgenius/dify-cloud-kit/pull/2