Files
multica/server/internal/storage/s3_test.go
pradeep7127 d9be9465c3 fix(storage): support custom S3 endpoints for self-hosted deployments (MinIO) (#681)
* fix(storage): support custom S3 endpoints for self-hosted deployments

When AWS_ENDPOINT_URL is set, the S3 client now uses path-style
addressing and routes requests to the custom endpoint (e.g. MinIO).
Returns path-style URLs (endpoint/bucket/key) instead of virtual-hosted
URLs so attachments are accessible on local setups.

Also falls back to STANDARD storage class for custom endpoints since
MinIO and other S3-compatible stores do not support INTELLIGENT_TIERING.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(storage): handle custom endpoint URLs in KeyFromURL

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-11 20:35:31 +08:00

30 lines
814 B
Go

package storage
import "testing"
func TestS3StorageKeyFromURL_CustomEndpointPreservesNestedKey(t *testing.T) {
s := &S3Storage{
bucket: "test-bucket",
endpointURL: "http://localhost:9000",
}
rawURL := "http://localhost:9000/test-bucket/uploads/abc/file.png"
if got := s.KeyFromURL(rawURL); got != "uploads/abc/file.png" {
t.Fatalf("KeyFromURL(%q) = %q, want %q", rawURL, got, "uploads/abc/file.png")
}
}
func TestS3StorageKeyFromURL_CustomEndpointWithTrailingSlash(t *testing.T) {
s := &S3Storage{
bucket: "test-bucket",
endpointURL: "http://localhost:9000/",
}
rawURL := "http://localhost:9000/test-bucket/uploads/abc/file.png"
if got := s.KeyFromURL(rawURL); got != "uploads/abc/file.png" {
t.Fatalf("KeyFromURL(%q) = %q, want %q", rawURL, got, "uploads/abc/file.png")
}
}