Add R2 image uploads to admin
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
This commit is contained in:
parent
9186801c7f
commit
49a0d078da
16 changed files with 809 additions and 14 deletions
30
backend/internal/admin/r2_test.go
Normal file
30
backend/internal/admin/r2_test.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package admin
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestNormalizeR2ConfigSplitsBucketPath(t *testing.T) {
|
||||
cfg, err := normalizeR2Config(R2Config{
|
||||
Endpoint: "https://example.r2.cloudflarestorage.com/stroage",
|
||||
Bucket: "stroage/Image/",
|
||||
AccessKeyID: "access-key",
|
||||
SecretAccessKey: "secret-key",
|
||||
Region: "auto",
|
||||
PublicBaseURL: "r2.example.com",
|
||||
MaxUploadBytes: 20,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("normalizeR2Config returned error: %v", err)
|
||||
}
|
||||
if cfg.Endpoint != "https://example.r2.cloudflarestorage.com" {
|
||||
t.Fatalf("unexpected endpoint: %s", cfg.Endpoint)
|
||||
}
|
||||
if cfg.Bucket != "stroage" {
|
||||
t.Fatalf("unexpected bucket: %s", cfg.Bucket)
|
||||
}
|
||||
if cfg.Prefix != "Image" {
|
||||
t.Fatalf("unexpected prefix: %s", cfg.Prefix)
|
||||
}
|
||||
if cfg.PublicBaseURL != "https://r2.example.com" {
|
||||
t.Fatalf("unexpected public base URL: %s", cfg.PublicBaseURL)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue