This commit is contained in:
jiangyong 2026-03-17 12:16:58 +08:00
parent 43d91bd3d8
commit 593342b848
1 changed files with 9 additions and 3 deletions

View File

@ -4,10 +4,11 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/qiniu/go-sdk/v7/auth/qbox"
"github.com/qiniu/go-sdk/v7/storage"
"os" "os"
"time" "time"
"github.com/qiniu/go-sdk/v7/auth/qbox"
"github.com/qiniu/go-sdk/v7/storage"
) )
type QiniuConfig struct { type QiniuConfig struct {
@ -15,6 +16,7 @@ type QiniuConfig struct {
AK string AK string
SK string SK string
Timeout time.Duration Timeout time.Duration
Https bool
} }
type Qiniu struct { type Qiniu struct {
@ -167,7 +169,11 @@ func (s *Qiniu) Url(objectName string, expire time.Duration) string {
return "" return ""
} }
domain := "https://" + domains[0].Domain domain := "http://" + domains[0].Domain
if s.config.Https {
domain = "https://" + domains[0].Domain
}
if expire == 0 { if expire == 0 {
return storage.MakePublicURLv2(domain, objectName) return storage.MakePublicURLv2(domain, objectName)
} else { } else {