S3 visibility
I am uploading files via spatie media library to S3 (digital ocean spaces). Unfortunately setting the
->visibility('public')
does not get recognized. Am I doing something wrong, or am I missing something here?
12 Replies
This is in the upload, right? What were you expecting the visibility setting to do when uploading the file?
(On displaying the uploaded file (AFTER uploading),
visiblity(public)
will give just a URL to the image, and visibility(private)
will give a URL that has 5-min expiration parameters attached.)@DrByte I was expecting that it sets the ACL Headers accordingly. I can successfully set the permissions globally via
/config/media-library.php
and remote.extra_headers
by adding 'ACL' => 'public-read'
but that is globally.Nope, it doesn't set any per-file attributes. Setting private just means URL's to the uploaded file get pre-signed.
Oh ok thats a pitty, is there a way I can set those custom headers per file basis?
I believe there is a customProperties() method you can use.
Where is
->disk('s3')
?According to the plugin docs, setting the
visibility()
is ignored on uploads:
https://filamentphp.com/plugins/filament-spatie-media-library#configuring-the-storage-disk-and-directory
But, it does mention that setting visibility(private)
((it fails to clarify, but I believe should say) on the SpatieMediaLibraryImageEntry
or SpatieMediaLibraryImageColumn
components, not the Uploader component) will generate signed URLs for accessing the images despite their being private.Filament
Spatie Media Library by Filament - Filament
Filament support for Spatie's Laravel Media Library package.
Do you have any console errors? Maybe the external providers permissions aren’t set up correctly too.
I don't have to apply this command as I am only using the default disk. It is set to
do
which represents digital ocean spaces in my system - which is afaik s3
Ok from my point of view this is again a global solution, applied to the disc config instead of the media library config...
no errors sir!Did you config this?
yes I did, as the upload works as expected.
So what are the bucket settings on the S3 side? If that is set to private, then you will need to use visibility 'private' on the upload, so you get presigned links when accessing the files.
Or you could try setting the ACL to public-read on the file using custimProperties() on the upload element as I mentioned before.