Improve oss key names.

This commit is contained in:
Yang Luo
2021-04-27 18:11:41 +08:00
parent f0ffacb6a5
commit 3437885723
3 changed files with 24 additions and 23 deletions

View File

@@ -213,8 +213,8 @@ Now, Casdoor is running on port 8000. You can access Casdoor pages directly in y
``` ```
[provider] [provider]
accessid = id accessId = id
accesskey = key accessKey = key
bucket = bucket bucket = bucket
endpoint = endpoint endpoint = endpoint
``` ```

View File

@@ -1,5 +1,5 @@
[provider] [provider]
accessid = id accessId = id
accesskey = key accessKey = key
bucket = bucket bucket = bucket
endpoint = endpoint endpoint = endpoint

View File

@@ -16,9 +16,10 @@ package object
import ( import (
"bytes" "bytes"
awss3 "github.com/aws/aws-sdk-go/service/s3"
"github.com/qor/oss" "github.com/qor/oss"
"github.com/qor/oss/aliyun" "github.com/qor/oss/aliyun"
awss3 "github.com/aws/aws-sdk-go/service/s3"
//"github.com/qor/oss/qiniu" //"github.com/qor/oss/qiniu"
"github.com/qor/oss/s3" "github.com/qor/oss/s3"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
@@ -27,33 +28,33 @@ import (
var storage oss.StorageInterface var storage oss.StorageInterface
func AliyunInit(section *ini.Section) string { func AliyunInit(section *ini.Section) string {
accessID := section.Key("accessid").String() accessId := section.Key("accessId").String()
accessKey := section.Key("accesskey").String() accessKey := section.Key("accessKey").String()
bucket := section.Key("bucket").String() bucket := section.Key("bucket").String()
endpoint := section.Key("endpoint").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"
} }
storage = aliyun.New(&aliyun.Config{ storage = aliyun.New(&aliyun.Config{
AccessID: accessID, AccessID: accessId,
AccessKey: accessKey, AccessKey: accessKey,
Bucket: bucket, Bucket: bucket,
Endpoint: endpoint, Endpoint: endpoint,
}) })
return "" return ""
} }
//func QiniuInit(section *ini.Section) string { //func QiniuInit(section *ini.Section) string {
// accessID := section.Key("accessid").String() // accessId := section.Key("accessId").String()
// accessKey := section.Key("accesskey").String() // accessKey := section.Key("accessKey").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() // 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"
// } // }
// storage = qiniu.New(&qiniu.Config{ // storage = qiniu.New(&qiniu.Config{
// AccessID: accessID, // AccessID: accessId,
// AccessKey: accessKey, // AccessKey: accessKey,
// Bucket: bucket, // Bucket: bucket,
// Region: region, // Region: region,
@@ -63,21 +64,21 @@ func AliyunInit(section *ini.Section) string {
//} //}
func Awss3Init(section *ini.Section) string { func Awss3Init(section *ini.Section) string {
accessID := section.Key("accessid").String() accessId := section.Key("accessId").String()
accessKey := section.Key("accesskey").String() accessKey := section.Key("accessKey").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() 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"
} }
storage = s3.New(&s3.Config{ storage = s3.New(&s3.Config{
AccessID: accessID, AccessID: accessId,
AccessKey: accessKey, AccessKey: accessKey,
Region: region, Region: region,
Bucket: bucket, Bucket: bucket,
Endpoint: endpoint, Endpoint: endpoint,
ACL: awss3.BucketCannedACLPublicRead, ACL: awss3.BucketCannedACLPublicRead,
}) })
return "" return ""
} }