Skip to content

Commit

Permalink
question(page): fix aws s3 sdk for cf r2
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhan005 committed Dec 16, 2023
1 parent 0903083 commit 7a7cf1f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion route/question/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 7a7cf1f

Please sign in to comment.