From 7a7cf1fdecef9928031cce152ad311ffeeeff942 Mon Sep 17 00:00:00 2001 From: E99p1ant Date: Sat, 16 Dec 2023 18:18:10 +0800 Subject: [PATCH] question(page): fix aws s3 sdk for cf r2 --- route/question/page.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/route/question/page.go b/route/question/page.go index 91ade27..291c8f4 100644 --- a/route/question/page.go +++ b/route/question/page.go @@ -269,13 +269,16 @@ func uploadImage(ctx context.Context, opts uploadImageOptions) error { r2Resolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) { return aws.Endpoint{ - URL: conf.Upload.ImageEndpoint, + URL: conf.Upload.ImageEndpoint, + HostnameImmutable: true, + Source: aws.EndpointSourceCustom, }, nil }) cfg, err := config.LoadDefaultConfig(ctx.Request().Context(), config.WithEndpointResolverWithOptions(r2Resolver), config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(conf.Upload.ImageAccessID, conf.Upload.ImageAccessSecret, "")), + config.WithRegion("auto"), ) if err != nil { return errors.Wrap(err, "load config")