feat(obs): 支持华为云obs存储
This commit is contained in:
@@ -199,7 +199,7 @@ func (c ChunkingConfig) ResolveParserEngine(fileType string) string {
|
||||
// StorageProviderConfig stores the KB-level storage provider selection.
|
||||
// Credentials are managed at the tenant level (StorageEngineConfig).
|
||||
type StorageProviderConfig struct {
|
||||
Provider string `yaml:"provider" json:"provider"` // "local", "minio", "cos", "tos", "s3", "oss", "ks3"
|
||||
Provider string `yaml:"provider" json:"provider"` // "local", "minio", "cos", "tos", "s3", "oss", "ks3", "obs"
|
||||
}
|
||||
|
||||
func (c StorageProviderConfig) Value() (driver.Value, error) {
|
||||
@@ -220,13 +220,26 @@ func (c *StorageProviderConfig) Scan(value interface{}) error {
|
||||
// Deprecated: StorageConfig is the legacy COS configuration stored in the cos_config column.
|
||||
// New code should use StorageProviderConfig. Kept for backward compatibility with old data.
|
||||
type StorageConfig struct {
|
||||
SecretID string `yaml:"secret_id" json:"secret_id"`
|
||||
SecretKey string `yaml:"secret_key" json:"secret_key"`
|
||||
Region string `yaml:"region" json:"region"`
|
||||
// Secret ID (COS) / Access Key ID (S3, MinIO)
|
||||
SecretID string `yaml:"secret_id" json:"secret_id"`
|
||||
// Secret Key (COS) / Secret Access Key (S3, MinIO)
|
||||
SecretKey string `yaml:"secret_key" json:"secret_key"`
|
||||
// Region
|
||||
Region string `yaml:"region" json:"region"`
|
||||
// Bucket Name
|
||||
BucketName string `yaml:"bucket_name" json:"bucket_name"`
|
||||
AppID string `yaml:"app_id" json:"app_id"`
|
||||
// App ID (COS specific)
|
||||
AppID string `yaml:"app_id" json:"app_id"`
|
||||
// Path Prefix
|
||||
PathPrefix string `yaml:"path_prefix" json:"path_prefix"`
|
||||
Provider string `yaml:"provider" json:"provider"`
|
||||
// Provider: "cos", "minio", "s3"
|
||||
Provider string `yaml:"provider" json:"provider"`
|
||||
// Endpoint (S3 specific) - e.g., s3.amazonaws.com, oss-cn-hangzhou.aliyuncs.com
|
||||
Endpoint string `yaml:"endpoint" json:"endpoint,omitempty"`
|
||||
// UseSSL (S3 specific) - whether to use HTTPS
|
||||
UseSSL bool `yaml:"use_ssl" json:"use_ssl,omitempty"`
|
||||
// ForcePathStyle (S3 specific) - whether to use path-style URLs
|
||||
ForcePathStyle bool `yaml:"force_path_style" json:"force_path_style,omitempty"`
|
||||
}
|
||||
|
||||
func (c StorageConfig) Value() (driver.Value, error) {
|
||||
@@ -313,7 +326,7 @@ func InferStorageFromFilePath(filePath string) string {
|
||||
// e.g. "minio://bucket/key" → "minio", "local://tenant/file.pdf" → "local"
|
||||
// Returns "" if the path does not use a known provider scheme.
|
||||
func ParseProviderScheme(filePath string) string {
|
||||
for _, provider := range []string{"local", "minio", "cos", "tos", "s3", "oss", "ks3"} {
|
||||
for _, provider := range []string{"local", "minio", "cos", "tos", "s3", "oss", "ks3", "obs"} {
|
||||
if strings.HasPrefix(filePath, provider+"://") {
|
||||
return provider
|
||||
}
|
||||
|
||||
@@ -351,10 +351,10 @@ func (c *ParserEngineConfig) Scan(value interface{}) error {
|
||||
return json.Unmarshal(b, c)
|
||||
}
|
||||
|
||||
// StorageEngineConfig holds tenant-level storage engine parameters for Local, MinIO, COS, TOS, S3, OSS, and KS3.
|
||||
// StorageEngineConfig holds tenant-level storage engine parameters for Local, MinIO, COS, TOS, S3, OSS, KS3, and OBS.
|
||||
// Knowledge bases select which provider to use; parameters are read from here.
|
||||
type StorageEngineConfig struct {
|
||||
DefaultProvider string `json:"default_provider"` // "local", "minio", "cos", "tos", "s3", "oss", "ks3"
|
||||
DefaultProvider string `json:"default_provider"` // "local", "minio", "cos", "tos", "s3", "oss", "ks3", "obs"
|
||||
Local *LocalEngineConfig `json:"local,omitempty"`
|
||||
MinIO *MinIOEngineConfig `json:"minio,omitempty"`
|
||||
COS *COSEngineConfig `json:"cos,omitempty"`
|
||||
@@ -362,6 +362,7 @@ type StorageEngineConfig struct {
|
||||
S3 *S3EngineConfig `json:"s3,omitempty"`
|
||||
OSS *OSSEngineConfig `json:"oss,omitempty"`
|
||||
KS3 *KS3EngineConfig `json:"ks3,omitempty"`
|
||||
OBS *OBSEngineConfig `json:"obs,omitempty"`
|
||||
}
|
||||
|
||||
// LocalEngineConfig is for local file system storage (single-machine deployment only).
|
||||
@@ -403,12 +404,14 @@ type TOSEngineConfig struct {
|
||||
|
||||
// S3EngineConfig is for AWS S3 and S3-compatible object storage.
|
||||
type S3EngineConfig struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
Region string `json:"region"`
|
||||
AccessKey string `json:"access_key"`
|
||||
SecretKey string `json:"secret_key"`
|
||||
BucketName string `json:"bucket_name"`
|
||||
PathPrefix string `json:"path_prefix"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
Region string `json:"region"`
|
||||
AccessKey string `json:"access_key"`
|
||||
SecretKey string `json:"secret_key"`
|
||||
BucketName string `json:"bucket_name"`
|
||||
PathPrefix string `json:"path_prefix"`
|
||||
UseSSL bool `json:"use_ssl"`
|
||||
ForcePathStyle bool `json:"force_path_style"`
|
||||
}
|
||||
|
||||
// OSSEngineConfig is for Alibaba Cloud OSS (对象存储服务).
|
||||
@@ -434,6 +437,17 @@ type KS3EngineConfig struct {
|
||||
PathPrefix string `json:"path_prefix"`
|
||||
}
|
||||
|
||||
// OBSEngineConfig is for Huawei Cloud OBS (对象存储服务).
|
||||
type OBSEngineConfig struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
Region string `json:"region"`
|
||||
AccessKey string `json:"access_key"`
|
||||
SecretKey string `json:"secret_key"`
|
||||
BucketName string `json:"bucket_name"`
|
||||
PathPrefix string `json:"path_prefix"`
|
||||
UseSSL bool `json:"use_ssl"`
|
||||
}
|
||||
|
||||
// Value implements the driver.Valuer interface for StorageEngineConfig
|
||||
func (c *StorageEngineConfig) Value() (driver.Value, error) {
|
||||
if c == nil {
|
||||
|
||||
Reference in New Issue
Block a user