fix(storage): add S3 provider scheme support to frontend and backend allowlists

The S3 storage adapter (s3.go) was added in e309e0b but the provider
scheme integration was incomplete — ParseProviderScheme() and frontend
security.ts were not updated, causing s3:// URLs to fail in the /files
proxy, VLM image processing, and frontend rendering.

Additionally, S3-compatible services (MinIO, Ceph, etc.) require
path-style addressing (endpoint/bucket/key) but the SDK client only
used virtual-hosted style. The deprecated WithEndpointResolver API
is replaced with BaseEndpoint, and path-style is auto-enabled for
non-AWS endpoints (detected by amazonaws.com in the URL).

Changes:
- types/knowledgebase.go: add "s3" to ParseProviderScheme()
- file/s3.go: auto path-style for S3-compatible endpoints + replace
  deprecated WithEndpointResolver with BaseEndpoint
- frontend/security.ts: add s3 to 5 provider scheme allowlists
- knowledgebase_test.go: add ParseProviderScheme + InferStorage tests
- s3_test.go: add path-style detection + parseS3FilePath tests
This commit is contained in:
ochan.kwon
2026-03-30 15:58:13 +09:00
committed by lyingbug
parent 66f4207bbc
commit 5c0cda3630
5 changed files with 178 additions and 9 deletions
+8 -3
View File
@@ -43,11 +43,16 @@ func newS3Client(endpoint, accessKey, secretKey, bucketName, region, pathPrefix
return nil, fmt.Errorf("failed to load AWS config: %w", err)
}
// Create S3 client with custom endpoint if provided
// Create S3 client with custom endpoint if provided.
// For S3-compatible services (non-AWS), use path-style addressing
// (endpoint/bucket/key) instead of virtual-hosted style (bucket.endpoint/key).
var client *s3.Client
if endpoint != "" {
// Use S3-specific endpoint resolver for custom endpoints
client = s3.NewFromConfig(cfg, s3.WithEndpointResolver(s3.EndpointResolverFromURL(endpoint)))
usePathStyle := !strings.Contains(endpoint, "amazonaws.com")
client = s3.NewFromConfig(cfg, func(o *s3.Options) {
o.BaseEndpoint = aws.String(endpoint)
o.UsePathStyle = usePathStyle
})
} else {
// Standard AWS S3
client = s3.NewFromConfig(cfg)