mirror of
https://github.com/knadh/listmonk.git
synced 2025-03-01 00:35:28 +08:00
Add explicit public-read
ACL to public S3 uploads. Closes #496.
This commit is contained in:
parent
05585b701b
commit
7aa850824c
1 changed files with 8 additions and 3 deletions
|
@ -61,7 +61,7 @@ func NewS3Store(opt Opt) (media.Store, error) {
|
|||
// Put takes in the filename, the content type and file object itself and uploads to S3.
|
||||
func (c *Client) Put(name string, cType string, file io.ReadSeeker) (string, error) {
|
||||
// Upload input parameters
|
||||
upParams := simples3.UploadInput{
|
||||
p := simples3.UploadInput{
|
||||
Bucket: c.opts.Bucket,
|
||||
ContentType: cType,
|
||||
FileName: name,
|
||||
|
@ -70,8 +70,13 @@ func (c *Client) Put(name string, cType string, file io.ReadSeeker) (string, err
|
|||
// Paths inside the bucket should not start with /.
|
||||
ObjectKey: c.makeBucketPath(name),
|
||||
}
|
||||
// Perform an upload.
|
||||
if _, err := c.s3.FileUpload(upParams); err != nil {
|
||||
|
||||
if c.opts.BucketType == "public" {
|
||||
p.ACL = "public-read"
|
||||
}
|
||||
|
||||
// Upload.
|
||||
if _, err := c.s3.FileUpload(p); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return name, nil
|
||||
|
|
Loading…
Reference in a new issue