mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
Support oss domain.
This commit is contained in:
parent
3437885723
commit
6002395d12
@ -1,5 +1,6 @@
|
|||||||
[provider]
|
[provider]
|
||||||
|
endpoint = endpoint
|
||||||
accessId = id
|
accessId = id
|
||||||
accessKey = key
|
accessKey = key
|
||||||
bucket = bucket
|
domain = domain
|
||||||
endpoint = endpoint
|
bucket = bucket
|
@ -16,6 +16,7 @@ package object
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
awss3 "github.com/aws/aws-sdk-go/service/s3"
|
awss3 "github.com/aws/aws-sdk-go/service/s3"
|
||||||
"github.com/qor/oss"
|
"github.com/qor/oss"
|
||||||
@ -26,12 +27,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var storage oss.StorageInterface
|
var storage oss.StorageInterface
|
||||||
|
var domain string
|
||||||
|
|
||||||
func AliyunInit(section *ini.Section) string {
|
func AliyunInit(section *ini.Section) string {
|
||||||
|
endpoint := section.Key("endpoint").String()
|
||||||
accessId := section.Key("accessId").String()
|
accessId := section.Key("accessId").String()
|
||||||
accessKey := section.Key("accessKey").String()
|
accessKey := section.Key("accessKey").String()
|
||||||
|
domain = section.Key("domain").String()
|
||||||
bucket := section.Key("bucket").String()
|
bucket := section.Key("bucket").String()
|
||||||
endpoint := section.Key("endpoint").String()
|
|
||||||
if accessId == "" || accessKey == "" || bucket == "" || endpoint == "" {
|
if accessId == "" || accessKey == "" || bucket == "" || endpoint == "" {
|
||||||
return "Config oss.conf wrong"
|
return "Config oss.conf wrong"
|
||||||
}
|
}
|
||||||
@ -45,11 +48,12 @@ func AliyunInit(section *ini.Section) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//func QiniuInit(section *ini.Section) string {
|
//func QiniuInit(section *ini.Section) string {
|
||||||
|
// endpoint := section.Key("endpoint").String()
|
||||||
// accessId := section.Key("accessId").String()
|
// accessId := section.Key("accessId").String()
|
||||||
// accessKey := section.Key("accessKey").String()
|
// accessKey := section.Key("accessKey").String()
|
||||||
|
// domain = section.Key("domain").String()
|
||||||
// bucket := section.Key("bucket").String()
|
// bucket := section.Key("bucket").String()
|
||||||
// region := section.Key("region").String()
|
// region := section.Key("region").String()
|
||||||
// endpoint := section.Key("endpoint").String()
|
|
||||||
// if accessId == "" || accessKey == "" || bucket == "" || endpoint == "" || region == "" {
|
// if accessId == "" || accessKey == "" || bucket == "" || endpoint == "" || region == "" {
|
||||||
// return "Config oss.conf wrong"
|
// return "Config oss.conf wrong"
|
||||||
// }
|
// }
|
||||||
@ -64,11 +68,12 @@ func AliyunInit(section *ini.Section) string {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
func Awss3Init(section *ini.Section) string {
|
func Awss3Init(section *ini.Section) string {
|
||||||
|
endpoint := section.Key("endpoint").String()
|
||||||
accessId := section.Key("accessId").String()
|
accessId := section.Key("accessId").String()
|
||||||
accessKey := section.Key("accessKey").String()
|
accessKey := section.Key("accessKey").String()
|
||||||
|
domain = section.Key("domain").String()
|
||||||
bucket := section.Key("bucket").String()
|
bucket := section.Key("bucket").String()
|
||||||
region := section.Key("region").String()
|
region := section.Key("region").String()
|
||||||
endpoint := section.Key("endpoint").String()
|
|
||||||
if accessId == "" || accessKey == "" || bucket == "" || endpoint == "" || region == "" {
|
if accessId == "" || accessKey == "" || bucket == "" || endpoint == "" || region == "" {
|
||||||
return "Config oss.conf wrong"
|
return "Config oss.conf wrong"
|
||||||
}
|
}
|
||||||
@ -120,5 +125,5 @@ func UploadAvatar(username string, avatar []byte) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetAvatarPath() string {
|
func GetAvatarPath() string {
|
||||||
return "https://" + storage.GetEndpoint() + "/casdoor/avatar/"
|
return fmt.Sprintf("https://%s/casdoor/avatar/", domain)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user