Skip to content

Commit

Permalink
oss添加内网域名选项
Browse files Browse the repository at this point in the history
  • Loading branch information
togettoyou committed Apr 18, 2023
1 parent 1a7e0ee commit a64df94
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions server/pkg/ali/oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import (
func Verify() error {
ossInfo := caches.GetOSSInfo()
if ossInfo.Enable() {
client, err := oss.New(ossInfo.OSSEndpoint, ossInfo.OSSAccessKeyID, ossInfo.OSSAccessKeySecret)
endpoint := ossInfo.OSSEndpoint
if ossInfo.OSSLANEndpoint != "" {
endpoint = ossInfo.OSSLANEndpoint
}
client, err := oss.New(endpoint, ossInfo.OSSAccessKeyID, ossInfo.OSSAccessKeySecret)
if err != nil {
return err
}
Expand All @@ -30,7 +34,11 @@ func Verify() error {
func UploadFile(objectKey, filePath string) (string, error) {
ossInfo := caches.GetOSSInfo()
if ossInfo.Enable() {
client, err := oss.New(ossInfo.OSSEndpoint, ossInfo.OSSAccessKeyID, ossInfo.OSSAccessKeySecret)
endpoint := ossInfo.OSSEndpoint
if ossInfo.OSSLANEndpoint != "" {
endpoint = ossInfo.OSSLANEndpoint
}
client, err := oss.New(endpoint, ossInfo.OSSAccessKeyID, ossInfo.OSSAccessKeySecret)
if err != nil {
return "", err
}
Expand Down
1 change: 1 addition & 0 deletions server/pkg/caches/oss_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type OSSInfo struct {
EnableOSS bool `json:"enable_oss"`
OSSBucketName string `json:"oss_bucket_name"`
OSSEndpoint string `json:"oss_endpoint"`
OSSLANEndpoint string `json:"oss_lan_endpoint"` // 内网地址,可选
OSSAccessKeyID string `json:"oss_access_key_id"`
OSSAccessKeySecret string `json:"oss_access_key_secret"`
}
Expand Down
6 changes: 5 additions & 1 deletion web/src/views/setting/oss/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
<el-form-item label="存储空间(Bucket)" prop="oss_bucket_name">
<el-input v-model="ruleForm.oss_bucket_name"></el-input>
</el-form-item>
<el-form-item label="访问域名(Endpoint)" prop="oss_endpoint">
<el-form-item label="外网访问域名(Endpoint)" prop="oss_endpoint">
<el-input v-model="ruleForm.oss_endpoint"></el-input>
</el-form-item>
<el-form-item label="内网上传域名(Endpoint)(可选)" prop="oss_lan_endpoint">
<el-input v-model="ruleForm.oss_lan_endpoint"></el-input>
</el-form-item>
<el-form-item label="访问密钥(AccessKeyId)" prop="oss_access_key_id">
<el-input v-model="ruleForm.oss_access_key_id"></el-input>
</el-form-item>
Expand Down Expand Up @@ -54,6 +57,7 @@ export default {
enable_oss: false,
oss_bucket_name: '',
oss_endpoint: '',
oss_lan_endpoint: '',
oss_access_key_id: '',
oss_access_key_secret: '',
},
Expand Down

0 comments on commit a64df94

Please sign in to comment.