From 5bd711afc6ae6e5bf9c07fcbd66b6d7654c5a51e Mon Sep 17 00:00:00 2001 From: XYenon <20698483+XYenon@users.noreply.github.com> Date: Thu, 5 May 2022 14:24:35 +0800 Subject: [PATCH] fix: catch s3 presign err (#1277) --- pkg/filesystem/driver/s3/handler.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/filesystem/driver/s3/handler.go b/pkg/filesystem/driver/s3/handler.go index cc47993..fe6007a 100644 --- a/pkg/filesystem/driver/s3/handler.go +++ b/pkg/filesystem/driver/s3/handler.go @@ -4,9 +4,6 @@ import ( "context" "errors" "fmt" - "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/chunk" - "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/chunk/backoff" - "github.com/cloudreve/Cloudreve/v3/pkg/util" "io" "net/http" "net/url" @@ -15,6 +12,10 @@ import ( "strings" "time" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/chunk" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/chunk/backoff" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" @@ -299,7 +300,10 @@ func (handler *Driver) Source( ttl = 3600 } - signedURL, _ := req.Presign(time.Duration(ttl) * time.Second) + signedURL, err := req.Presign(time.Duration(ttl) * time.Second) + if err != nil { + return "", err + } // 将最终生成的签名URL域名换成用户自定义的加速域名(如果有) finalURL, err := url.Parse(signedURL)