Red Bottle
Red Bottle

Reputation: 3080

How to set access rights for files uploaded to s3 server using fedemotta Yii2 extension?

I can properly upload files to my s3 bucket using fedemotta yii2-aws-sdk extension. I cannot access the files because I have to set access rights to each file I upload. My config looks something like this:

'components' => [
        'awssdk' => [
                'class' => 'fedemotta\awssdk\AwsSdk',
                'credentials' => [ 
                        'key' => 'ZXCV',
                        'secret' => 'zxcv',
                ],
                'region' => 'us-east-1',                    
                'version' => 'latest',
        ],

I found out that in the default yii2-file-upload extension, it can be done using setACL('public-read'). How do I do this in fedemotta extension?

Upvotes: 1

Views: 427

Answers (1)

Red Bottle
Red Bottle

Reputation: 3080

Solved.

Just add 'ACL' => 'public-read', to your upload function in the model

$this->s3->putObject(array(
            'Bucket'       => $bucket,
            'Key'          => $keyname,
            'SourceFile'   => $filepath,
            'ACL'          => 'public-read',
            ));`

Upvotes: 1

Related Questions