Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/sync-info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

name: Sync info
on:
pull_request:
branches: [dev, main]
push:
branches: [dev, main]

Expand All @@ -40,5 +38,3 @@ jobs:
title: "chore: Sync Plugin Info"
body: "Sync Plugin Info"
branch: "chore/sync-info"


25 changes: 24 additions & 1 deletion storage-aliyunoss/aliyunoss.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type StorageConfig struct {
AccessKeyID string `json:"access_key_id"`
AccessKeySecret string `json:"access_key_secret"`
VisitUrlPrefix string `json:"visit_url_prefix"`
ACL string `json:"acl"`
}

func init() {
Expand Down Expand Up @@ -121,7 +122,11 @@ func (s *Storage) UploadFile(ctx *plugin.GinContext, condition plugin.UploadFile
ObjectKey: objectKey,
Reader: open,
}
respBody, err := bucket.DoPutObject(request, nil)
var options []oss.Option
if s.Config.ACL == string(oss.ACLPublicRead) {
options = append(options, oss.ObjectACL(oss.ACLPublicRead))
}
respBody, err := bucket.DoPutObject(request, options)
if err != nil {
resp.OriginalError = fmt.Errorf("upload file failed: %v", err)
resp.DisplayErrorMsg = plugin.MakeTranslator(i18n.ErrUploadFileFailed)
Expand Down Expand Up @@ -246,6 +251,24 @@ func (s *Storage) ConfigFields() []plugin.ConfigField {
},
Value: s.Config.VisitUrlPrefix,
},
{
Name: "acl",
Type: plugin.ConfigTypeSelect,
Title: plugin.MakeTranslator(i18n.ConfigACLTitle),
Description: plugin.MakeTranslator(i18n.ConfigACLDescription),
Required: true,
Options: []plugin.ConfigFieldOption{
{
Label: plugin.MakeTranslator(i18n.ConfigACLOptionsDefault),
Value: string(oss.ACLDefault),
},
{
Label: plugin.MakeTranslator(i18n.ConfigACLOptionsPublicRead),
Value: string(oss.ACLPublicRead),
},
},
Value: s.Config.ACL,
},
}
}

Expand Down
10 changes: 10 additions & 0 deletions storage-aliyunoss/i18n/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ plugin:
other: Access URL prefix
description:
other: prefix of the final access address of the uploaded file, ending with '/' https://example.com/xxx/
acl:
title:
other: Object ACL
description:
other: Set Object ACL, default is consistent with the read and write permissions of the Bucket, can be modified to public read.
options:
default:
other: Default
public_read:
other: Public Read
err:
mis_storage_config:
other: Wrong storage configuration causes upload failure.
Expand Down
4 changes: 4 additions & 0 deletions storage-aliyunoss/i18n/translation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const (
ConfigAccessKeySecretDescription = "plugin.aliyunoss_storage.backend.config.access_key_secret.description"
ConfigVisitUrlPrefixTitle = "plugin.aliyunoss_storage.backend.config.visit_url_prefix.title"
ConfigVisitUrlPrefixDescription = "plugin.aliyunoss_storage.backend.config.visit_url_prefix.description"
ConfigACLTitle = "plugin.aliyunoss_storage.backend.config.acl.title"
ConfigACLDescription = "plugin.aliyunoss_storage.backend.config.acl.description"
ConfigACLOptionsDefault = "plugin.aliyunoss_storage.backend.config.acl.options.default"
ConfigACLOptionsPublicRead = "plugin.aliyunoss_storage.backend.config.acl.options.public_read"

ErrMisStorageConfig = "plugin.aliyunoss_storage.backend.err.mis_storage_config"
ErrFileNotFound = "plugin.aliyunoss_storage.backend.err.file_not_found"
Expand Down
10 changes: 10 additions & 0 deletions storage-aliyunoss/i18n/zh_CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ plugin:
other: 访问URL前缀
description:
other: 上传文件最终访问地址的前缀,以 '/' 结尾 https://example.com/xxx/
acl:
title:
other: Object ACL
description:
other: 设置 Object ACL,默认和 Bucket 的读写权限一致,可修改为公共读。
options:
default:
other: 默认
public_read:
other: 公共读
err:
mis_storage_config:
other: 错误的存储配置导致上传失败
Expand Down
2 changes: 1 addition & 1 deletion storage-aliyunoss/info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

slug_name: aliyunoss_storage
type: storage
version: 1.2.12
version: 1.2.13
author: answerdev
link: https://github.com/apache/answer-plugins/tree/main/storage-aliyunoss
10 changes: 10 additions & 0 deletions storage-tencentyuncos/i18n/en_US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ plugin:
other: Access URL prefix
description:
other: prefix of the final access address of the uploaded file, ending with '/' https://example.com/xxx/
acl:
title:
other: Object ACL
description:
other: Set Object ACL, default is consistent with the read and write permissions of the Bucket, can be modified to public read.
options:
default:
other: Default
public_read:
other: Public Read
err:
mis_storage_config:
other: Wrong storage configuration causes upload failure.
Expand Down
4 changes: 4 additions & 0 deletions storage-tencentyuncos/i18n/translation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const (
ConfigSecretKeyDescription = "plugin.tencentyuncos_storage.backend.config.secret_key.description"
ConfigVisitUrlPrefixTitle = "plugin.tencentyuncos_storage.backend.config.visit_url_prefix.title"
ConfigVisitUrlPrefixDescription = "plugin.tencentyuncos_storage.backend.config.visit_url_prefix.description"
ConfigACLTitle = "plugin.tencentyuncos_storage.backend.config.acl.title"
ConfigACLDescription = "plugin.tencentyuncos_storage.backend.config.acl.description"
ConfigACLOptionsDefault = "plugin.tencentyuncos_storage.backend.config.acl.options.default"
ConfigACLOptionsPublicRead = "plugin.tencentyuncos_storage.backend.config.acl.options.public_read"

ErrMisStorageConfig = "plugin.tencentyuncos_storage.backend.err.mis_storage_config"
ErrFileNotFound = "plugin.tencentyuncos_storage.backend.err.file_not_found"
Expand Down
10 changes: 10 additions & 0 deletions storage-tencentyuncos/i18n/zh_CN.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ plugin:
other: 访问URL前缀
description:
other: 上传文件最终访问地址的前缀,以 '/' 结尾 https://example.com/xxx/
acl:
title:
other: Object ACL
description:
other: 设置 Object ACL,默认和 Bucket 的读写权限一致,可修改为公共读。
options:
default:
other: 默认
public_read:
other: 公共读
err:
mis_storage_config:
other: 错误的存储配置导致上传失败
Expand Down
2 changes: 1 addition & 1 deletion storage-tencentyuncos/info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

slug_name: tencentyuncos_storage
type: storage
version: 1.0.3
version: 1.0.4
author: Luffy
link: https://github.com/apache/answer-plugins/tree/main/storage-tencentyuncos
29 changes: 28 additions & 1 deletion storage-tencentyuncos/tencentyuncos.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type StorageConfig struct {
SecretID string `json:"secret_id"`
SecretKey string `json:"secret_key"`
VisitUrlPrefix string `json:"visit_url_prefix"`
ACL string `json:"acl"`
}

func init() {
Expand Down Expand Up @@ -122,7 +123,15 @@ func (s *Storage) UploadFile(ctx *plugin.GinContext, condition plugin.UploadFile
defer openFile.Close()

objectKey := s.createObjectKey(file.Filename, condition.Source)
_, err = client.Object.Put(ctx, objectKey, openFile, nil)
var options *cos.ObjectPutOptions
if s.Config.ACL == "public-read" {
options = &cos.ObjectPutOptions{
ACLHeaderOptions: &cos.ACLHeaderOptions{
XCosACL: "public-read",
},
}
}
_, err = client.Object.Put(ctx, objectKey, openFile, options)
if err != nil {
resp.OriginalError = fmt.Errorf("upload file failed: %v", err)
resp.DisplayErrorMsg = plugin.MakeTranslator(i18n.ErrUploadFileFailed)
Expand Down Expand Up @@ -254,6 +263,24 @@ func (s *Storage) ConfigFields() []plugin.ConfigField {
},
Value: s.Config.VisitUrlPrefix,
},
{
Name: "acl",
Type: plugin.ConfigTypeSelect,
Title: plugin.MakeTranslator(i18n.ConfigACLTitle),
Description: plugin.MakeTranslator(i18n.ConfigACLDescription),
Required: true,
Options: []plugin.ConfigFieldOption{
{
Label: plugin.MakeTranslator(i18n.ConfigACLOptionsDefault),
Value: "default",
},
{
Label: plugin.MakeTranslator(i18n.ConfigACLOptionsPublicRead),
Value: "public-read",
},
},
Value: s.Config.ACL,
},
}
}

Expand Down