Laravel Spatie Media Library AWS s3 bucket Access Denied

1.5k Views Asked by At

Uploading User profile photo & cover photo using Spatie Media Library on the AWS s3 bucket.I have set the s3 bucket policy to public and on \config\media-library.php i have set extra_headers [ 'ACL' => 'public-read' ].

So when I upload the images it's proper work for profile and cover photo ( i.e, anyone able to view image using link ) but when thumb MediaConversion job run (Spatie\MediaLibrary\Conversions\Jobs\PerformConversionsJob) it's not setting proper ACL public read permission. It gives access denied error for thumb type collection.

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>6AKNWTC2XK1ST0YZ</RequestId>
<HostId>GfjHi2Z0viPuIkjYOm+cLGa3whddk0MVK6F4Ht/ChoNEEugqsgNDmG8f4+0YQLgor4SS+FPESDo=</HostId>
</Error>

On Model User.php

public function registerMediaConversions(Media $media = null): void
{
  

    $this->addMediaCollection('profile')->singleFile();
    $this->addMediaCollection('coverphoto')->singleFile();

 
    $this->addMediaConversion('thumb')->fit('crop', 80, 80);
}

\config\media-library.php

'remote' => [
  
        'extra_headers' => [
            'CacheControl' => 'max-age=604800',
             
            'ACL' => 'public-read',

        ],
    ],

Thanks,

How to resolve access denied for thumb MediaConversion job or any proper bucket policy to update for access denied

0

There are 0 best solutions below