Documentation
¶
Index ¶
- Variables
- func CheckCosConnectivity(ctx context.Context, bucketName, region, secretID, secretKey string) error
- func CheckKS3Connectivity(ctx context.Context, endpoint, region, accessKey, secretKey, bucketName string) error
- func CheckMinioConnectivity(ctx context.Context, endpoint, accessKeyID, secretAccessKey, bucketName string, ...) error
- func CheckObsConnectivity(ctx context.Context, endpoint, region, accessKey, secretKey, bucketName string) error
- func CheckOssConnectivity(ctx context.Context, endpoint, region, accessKey, secretKey, bucketName string) error
- func CheckS3Connectivity(ctx context.Context, endpoint, accessKey, secretKey, bucketName, region string) error
- func CheckS3ConnectivityWithOptions(ctx context.Context, endpoint, accessKey, secretKey, bucketName, region string, ...) error
- func CheckTosConnectivity(ctx context.Context, endpoint, region, accessKey, secretKey, bucketName string) error
- func NewBackendScopedFileService(backendID string, inner interfaces.FileService) interfaces.FileService
- func NewCosFileService(bucketName, region, secretId, secretKey, cosPathPrefix string) (interfaces.FileService, error)
- func NewCosFileServiceWithTempBucket(...) (interfaces.FileService, error)
- func NewDummyFileService() interfaces.FileService
- func NewFileServiceFromStorageConfig(provider string, sec *types.StorageEngineConfig, localBaseDir string) (interfaces.FileService, string, error)
- func NewGlobalResourceCatalogFileService(inner interfaces.FileService, catalog interfaces.ResourceCatalog) interfaces.FileService
- func NewKS3FileService(endpoint, region, accessKey, secretKey, bucketName, pathPrefix string) (interfaces.FileService, error)
- func NewLocalFileService(baseDir, externalURL string) interfaces.FileService
- func NewMinioFileService(endpoint, accessKeyID, secretAccessKey, bucketName string, useSSL bool) (interfaces.FileService, error)
- func NewObsFileService(endpoint, region, accessKeyID, secretAccessKey, bucketName string, ...) (interfaces.FileService, error)
- func NewOssFileService(endpoint, region, accessKey, secretKey, bucketName, pathPrefix string) (interfaces.FileService, error)
- func NewOssFileServiceWithTempBucket(...) (interfaces.FileService, error)
- func NewResourceCatalogFileService(inner interfaces.FileService, catalog interfaces.ResourceCatalog) interfaces.FileService
- func NewS3FileService(endpoint, accessKey, secretKey, bucketName, region, pathPrefix string) (interfaces.FileService, error)
- func NewS3FileServiceWithOptions(endpoint, accessKey, secretKey, bucketName, region, pathPrefix string, ...) (interfaces.FileService, error)
- func NewTosFileService(endpoint, region, accessKey, secretKey, bucketName, pathPrefix string) (interfaces.FileService, error)
- func NewTosFileServiceWithTempBucket(...) (interfaces.FileService, error)
- func ResolveTenantFileServiceWithFallback(ctx context.Context, logTag string, tenant *types.Tenant, ...) (fileSvc interfaces.FileService, resolvedProvider string, ok bool)
- type DummyFileService
- func (s *DummyFileService) CheckConnectivity(ctx context.Context) error
- func (s *DummyFileService) CopyFile(ctx context.Context, srcPath string, tenantID uint64, knowledgeID string) (string, error)
- func (s *DummyFileService) DeleteFile(ctx context.Context, filePath string) error
- func (s *DummyFileService) GetFile(ctx context.Context, filePath string) (io.ReadCloser, error)
- func (s *DummyFileService) GetFileURL(ctx context.Context, filePath string) (string, error)
- func (s *DummyFileService) SaveBytes(ctx context.Context, data []byte, tenantID uint64, fileName string, temp bool) (string, error)
- func (s *DummyFileService) SaveFile(ctx context.Context, file *multipart.FileHeader, tenantID uint64, ...) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrCrossBackendCopy = errors.New("file: cross-backend copy not supported")
ErrCrossBackendCopy is returned by CopyFile implementations when the source path belongs to a different storage provider than the destination service. PR1 only supports same-backend (server-side) copies; cross-backend streaming copy is intentionally not implemented yet.
Functions ¶
func CheckCosConnectivity ¶
func CheckCosConnectivity(ctx context.Context, bucketName, region, secretID, secretKey string) error
CheckCosConnectivity tests COS connectivity using the provided credentials. It creates a temporary service instance internally and delegates to CheckConnectivity.
func CheckKS3Connectivity ¶
func CheckKS3Connectivity(ctx context.Context, endpoint, region, accessKey, secretKey, bucketName string) error
CheckKS3Connectivity tests KS3 connectivity using the provided credentials.
func CheckMinioConnectivity ¶
func CheckMinioConnectivity(ctx context.Context, endpoint, accessKeyID, secretAccessKey, bucketName string, useSSL bool) error
CheckMinioConnectivity tests MinIO connectivity using the provided credentials. It creates a temporary service instance internally and delegates to CheckConnectivity.
func CheckObsConnectivity ¶
func CheckOssConnectivity ¶
func CheckOssConnectivity(ctx context.Context, endpoint, region, accessKey, secretKey, bucketName string) error
CheckOssConnectivity tests OSS connectivity using the provided credentials.
func CheckS3Connectivity ¶
func CheckS3Connectivity(ctx context.Context, endpoint, accessKey, secretKey, bucketName, region string) error
CheckS3Connectivity tests S3 connectivity using the provided credentials. It creates a temporary service instance internally and delegates to CheckConnectivity.
func CheckTosConnectivity ¶
func CheckTosConnectivity(ctx context.Context, endpoint, region, accessKey, secretKey, bucketName string) error
CheckTosConnectivity tests TOS connectivity using the provided credentials.
func NewBackendScopedFileService ¶
func NewBackendScopedFileService(backendID string, inner interfaces.FileService) interfaces.FileService
func NewCosFileService ¶
func NewCosFileService(bucketName, region, secretId, secretKey, cosPathPrefix string) (interfaces.FileService, error)
NewCosFileService creates a new COS file service instance
func NewCosFileServiceWithTempBucket ¶
func NewCosFileServiceWithTempBucket(bucketName, region, secretId, secretKey, cosPathPrefix, tempBucketName, tempRegion string) (interfaces.FileService, error)
NewCosFileServiceWithTempBucket creates a new COS file service instance with optional temp bucket
func NewDummyFileService ¶
func NewDummyFileService() interfaces.FileService
NewDummyFileService creates a new instance of DummyFileService
func NewFileServiceFromStorageConfig ¶
func NewFileServiceFromStorageConfig( provider string, sec *types.StorageEngineConfig, localBaseDir string, ) (interfaces.FileService, string, error)
NewFileServiceFromStorageConfig builds a provider-specific FileService from tenant storage config. provider can be empty; in that case it falls back to sec.DefaultProvider. Returns the resolved provider name together with the service.
func NewGlobalResourceCatalogFileService ¶ added in v0.9.0
func NewGlobalResourceCatalogFileService( inner interfaces.FileService, catalog interfaces.ResourceCatalog, ) interfaces.FileService
NewGlobalResourceCatalogFileService pins writes to the process-wide driver's concrete instance, independently of workspace defaults and legacy aliases.
func NewKS3FileService ¶
func NewKS3FileService(endpoint, region, accessKey, secretKey, bucketName, pathPrefix string) (interfaces.FileService, error)
NewKS3FileService creates a KS3 file service and ensures the bucket exists.
func NewLocalFileService ¶
func NewLocalFileService(baseDir, externalURL string) interfaces.FileService
NewLocalFileService creates a new local file service instance. externalURL is the externally-reachable base URL (e.g. "https://weknora.example.com"); when set, GetFileURL returns presigned HTTP URLs instead of local:// paths.
func NewMinioFileService ¶
func NewMinioFileService(endpoint, accessKeyID, secretAccessKey, bucketName string, useSSL bool, ) (interfaces.FileService, error)
NewMinioFileService creates a MinIO file service. It verifies that the bucket exists and creates it if missing.
func NewObsFileService ¶
func NewObsFileService( endpoint, region, accessKeyID, secretAccessKey, bucketName string, pathPrefix string, ) (interfaces.FileService, error)
func NewOssFileService ¶
func NewOssFileService(endpoint, region, accessKey, secretKey, bucketName, pathPrefix string) (interfaces.FileService, error)
NewOssFileService creates an Aliyun OSS file service. It verifies that the bucket exists and creates it if missing.
func NewOssFileServiceWithTempBucket ¶
func NewOssFileServiceWithTempBucket(endpoint, region, accessKey, secretKey, bucketName, pathPrefix, tempBucketName, tempRegion string) (interfaces.FileService, error)
NewOssFileServiceWithTempBucket creates an Aliyun OSS file service with optional temp bucket.
func NewResourceCatalogFileService ¶
func NewResourceCatalogFileService( inner interfaces.FileService, catalog interfaces.ResourceCatalog, ) interfaces.FileService
NewResourceCatalogFileService decorates a physical FileService with stable resource registration and resolution.
func NewS3FileService ¶
func NewS3FileService(endpoint, accessKey, secretKey, bucketName, region, pathPrefix string, ) (interfaces.FileService, error)
NewS3FileService creates an AWS S3 file service. It verifies that the bucket exists and creates it if missing.
func NewS3FileServiceWithOptions ¶
func NewS3FileServiceWithOptions(endpoint, accessKey, secretKey, bucketName, region, pathPrefix string, forcePathStyle bool) (interfaces.FileService, error)
NewS3FileServiceWithOptions is the instance-aware S3 constructor. Existing callers keep the historical endpoint-based path-style inference.
func NewTosFileService ¶
func NewTosFileService(endpoint, region, accessKey, secretKey, bucketName, pathPrefix string) (interfaces.FileService, error)
NewTosFileService creates a TOS file service.
func NewTosFileServiceWithTempBucket ¶
func NewTosFileServiceWithTempBucket(endpoint, region, accessKey, secretKey, bucketName, pathPrefix, tempBucketName, tempRegion string) (interfaces.FileService, error)
NewTosFileServiceWithTempBucket creates a TOS file service with optional temp bucket.
func ResolveTenantFileServiceWithFallback ¶
func ResolveTenantFileServiceWithFallback( ctx context.Context, logTag string, tenant *types.Tenant, backendID, provider, absDir string, storageResolver interfaces.StorageBackendResolver, globalFileService interfaces.FileService, ) (fileSvc interfaces.FileService, resolvedProvider string, ok bool)
ResolveTenantFileServiceWithFallback applies the storage resolution and fallback rule shared by file proxies and artifact downloads: when tenant-level resolution fails and the requested provider matches the process-global STORAGE_TYPE, serve through the global file service instead of failing. Returns ok=false (already logged) when no service can be resolved; the caller decides the HTTP status.
Types ¶
type DummyFileService ¶
type DummyFileService struct{}
DummyFileService is a no-op implementation of the FileService interface used for testing or when file storage is not required
func (*DummyFileService) CheckConnectivity ¶
func (s *DummyFileService) CheckConnectivity(ctx context.Context) error
CheckConnectivity always succeeds for the dummy service.
func (*DummyFileService) CopyFile ¶
func (s *DummyFileService) CopyFile(ctx context.Context, srcPath string, tenantID uint64, knowledgeID string) (string, error)
CopyFile is a no-op for the dummy service: it logs a warning and returns the source path unchanged (the shared reference is intentional in this stub).
func (*DummyFileService) DeleteFile ¶
func (s *DummyFileService) DeleteFile(ctx context.Context, filePath string) error
DeleteFile is a no-op operation that always succeeds
func (*DummyFileService) GetFile ¶
func (s *DummyFileService) GetFile(ctx context.Context, filePath string) (io.ReadCloser, error)
GetFile always returns an error as dummy service doesn't store files
func (*DummyFileService) GetFileURL ¶
GetFileURL returns the file path as URL (dummy implementation)