mirror of
https://github.com/Luzifer/cloudbox.git
synced 2024-11-09 22:50:09 +00:00
Allow specifying default ACL through parameters
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
ec3cd88486
commit
5cf68673a3
1 changed files with 12 additions and 4 deletions
|
@ -23,6 +23,7 @@ import (
|
||||||
type Provider struct {
|
type Provider struct {
|
||||||
bucket string
|
bucket string
|
||||||
bucketRegion string
|
bucketRegion string
|
||||||
|
defaultACL string
|
||||||
s3 *s3.S3
|
s3 *s3.S3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +52,18 @@ func New(uri string) (providers.CloudProvider, error) {
|
||||||
sess := session.Must(session.NewSession(cfg))
|
sess := session.Must(session.NewSession(cfg))
|
||||||
svc := s3.New(sess)
|
svc := s3.New(sess)
|
||||||
|
|
||||||
return &Provider{
|
p := &Provider{
|
||||||
bucket: u.Host,
|
bucket: u.Host,
|
||||||
bucketRegion: region,
|
bucketRegion: region,
|
||||||
|
defaultACL: s3.ObjectCannedACLPrivate,
|
||||||
s3: svc,
|
s3: svc,
|
||||||
}, nil
|
}
|
||||||
|
|
||||||
|
if acl := u.Query().Get("acl"); acl == s3.ObjectCannedACLPublicRead || acl == s3.ObjectCannedACLPrivate {
|
||||||
|
p.defaultACL = acl
|
||||||
|
}
|
||||||
|
|
||||||
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Provider) Capabilities() providers.Capability {
|
func (p *Provider) Capabilities() providers.Capability {
|
||||||
|
@ -161,7 +169,7 @@ func (p *Provider) getFileACL(relativeName string) string {
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return s3.ObjectCannedACLPrivate
|
return p.defaultACL
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, g := range objACL.Grants {
|
for _, g := range objACL.Grants {
|
||||||
|
@ -173,5 +181,5 @@ func (p *Provider) getFileACL(relativeName string) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s3.ObjectCannedACLPrivate
|
return p.defaultACL
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue