1
0
Fork 0
mirror of https://github.com/Luzifer/cloudbox.git synced 2024-12-22 18:51:21 +00:00

Allow specifying default ACL through parameters

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2019-06-30 04:54:04 +02:00
parent ec3cd88486
commit 5cf68673a3
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -23,6 +23,7 @@ import (
type Provider struct {
bucket string
bucketRegion string
defaultACL string
s3 *s3.S3
}
@ -51,11 +52,18 @@ func New(uri string) (providers.CloudProvider, error) {
sess := session.Must(session.NewSession(cfg))
svc := s3.New(sess)
return &Provider{
p := &Provider{
bucket: u.Host,
bucketRegion: region,
defaultACL: s3.ObjectCannedACLPrivate,
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 {
@ -161,7 +169,7 @@ func (p *Provider) getFileACL(relativeName string) string {
})
if err != nil {
return s3.ObjectCannedACLPrivate
return p.defaultACL
}
for _, g := range objACL.Grants {
@ -173,5 +181,5 @@ func (p *Provider) getFileACL(relativeName string) string {
}
}
return s3.ObjectCannedACLPrivate
return p.defaultACL
}