refactor: simplify image handling in _resolve_images function

- Removed the image storage handling from the `_resolve_images` function, which now only decodes images and returns them as inline bytes.
- Updated the function's docstring to clarify that image persistence is managed by the Go App, and the return value for `image_dir_path` is always empty.
- Adjusted related gRPC and protobuf files to remove the `ConvertToPDF` method and its associated types, streamlining the API.
- Enhanced security measures in the frontend by implementing a placeholder for provider images and ensuring proper hydration of protected file images.

These changes improve the clarity and efficiency of image processing and API interactions within the application.
This commit is contained in:
wizardchen
2026-03-03 21:30:27 +08:00
committed by lyingbug
parent 894d2c060a
commit 4192cfd072
26 changed files with 835 additions and 897 deletions
-1
View File
@@ -11,7 +11,6 @@ type ReadRequest struct {
ParserEngine string
RequestID string
ParserEngineOverrides map[string]string
ImageStorage map[string]string // storage provider config (provider, endpoint, bucket, ...)
}
// ReadResult is the transport-agnostic result of document reading.
+2 -2
View File
@@ -104,8 +104,8 @@ type ImageMultimodalPayload struct {
KnowledgeID string `json:"knowledge_id"`
KnowledgeBaseID string `json:"knowledge_base_id"`
ChunkID string `json:"chunk_id"` // parent text chunk
ImageURL string `json:"image_url"` // serving URL (/files/images/xxx.png)
ImageLocalPath string `json:"image_local_path"` // absolute path on disk
ImageURL string `json:"image_url"` // provider:// URL (e.g. local://..., minio://...)
ImageLocalPath string `json:"image_local_path"` // deprecated: kept for backward compat with in-flight tasks
EnableOCR bool `json:"enable_ocr"`
EnableCaption bool `json:"enable_caption"`
}
+19 -6
View File
@@ -230,21 +230,34 @@ func (kb *KnowledgeBase) SetStorageProvider(provider string) {
// InferStorageFromFilePath deduces the storage provider from a file path format.
// Used as a safety fallback when the KB's configured provider doesn't match the data.
// Supports provider:// scheme (local://, minio://, cos://, tos://),
// unified /files/{provider}/... format, and legacy formats.
func InferStorageFromFilePath(filePath string) string {
// Provider scheme format: provider://...
if p := ParseProviderScheme(filePath); p != "" {
return p
}
// Legacy formats
switch {
case strings.HasPrefix(filePath, "minio://"):
return "minio"
case strings.HasPrefix(filePath, "tos://"):
return "tos"
case strings.HasPrefix(filePath, "https://") && strings.Contains(filePath, ".cos."):
return "cos"
case strings.HasPrefix(filePath, "/"):
return "local"
default:
return ""
}
}
// ParseProviderScheme extracts the provider from a provider:// scheme path.
// 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"} {
if strings.HasPrefix(filePath, provider+"://") {
return provider
}
}
return ""
}
// ImageProcessingConfig represents the image processing configuration
type ImageProcessingConfig struct {
// Model ID