@@ -25,7 +25,6 @@ import (
2525 "encoding/hex"
2626 "encoding/json"
2727 "fmt"
28- "os"
2928 "path/filepath"
3029 "strings"
3130 "time"
@@ -41,11 +40,6 @@ import (
4140//go:embed info.yaml
4241var Info embed.FS
4342
44- var (
45- // aclPublicRead is the environment variable for some special platforms such as digital ocean
46- aclPublicRead = os .Getenv ("ACL_PUBLIC_READ" )
47- )
48-
4943type Storage struct {
5044 Config * StorageConfig
5145}
@@ -57,6 +51,7 @@ type StorageConfig struct {
5751 AccessKeyID string `json:"access_key_id"`
5852 AccessKeySecret string `json:"access_key_secret"`
5953 VisitUrlPrefix string `json:"visit_url_prefix"`
54+ ACL string `json:"acl"`
6055}
6156
6257func init () {
@@ -128,7 +123,7 @@ func (s *Storage) UploadFile(ctx *plugin.GinContext, condition plugin.UploadFile
128123 Reader : open ,
129124 }
130125 var options []oss.Option
131- if len ( aclPublicRead ) > 0 {
126+ if s . Config . ACL == string ( oss . ACLPublicRead ) {
132127 options = append (options , oss .ObjectACL (oss .ACLPublicRead ))
133128 }
134129 respBody , err := bucket .DoPutObject (request , options )
@@ -256,6 +251,24 @@ func (s *Storage) ConfigFields() []plugin.ConfigField {
256251 },
257252 Value : s .Config .VisitUrlPrefix ,
258253 },
254+ {
255+ Name : "acl" ,
256+ Type : plugin .ConfigTypeSelect ,
257+ Title : plugin .MakeTranslator (i18n .ConfigACLTitle ),
258+ Description : plugin .MakeTranslator (i18n .ConfigACLDescription ),
259+ Required : true ,
260+ Options : []plugin.ConfigFieldOption {
261+ {
262+ Label : plugin .MakeTranslator (i18n .ConfigACLOptionsDefault ),
263+ Value : string (oss .ACLDefault ),
264+ },
265+ {
266+ Label : plugin .MakeTranslator (i18n .ConfigACLOptionsPublicRead ),
267+ Value : string (oss .ACLPublicRead ),
268+ },
269+ },
270+ Value : s .Config .ACL ,
271+ },
259272 }
260273}
261274
0 commit comments