F
Filament2y ago
N1XN

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?
SpatieMediaLibraryFileUpload::make('images')
->label('Bilder')
->acceptedFileTypes(['image/jpg', 'image/jpeg', 'image/png'])
->collection('images')
->multiple()
->visibility('public') // doing nothing...
->required(),
SpatieMediaLibraryFileUpload::make('images')
->label('Bilder')
->acceptedFileTypes(['image/jpg', 'image/jpeg', 'image/png'])
->collection('images')
->multiple()
->visibility('public') // doing nothing...
->required(),
12 Replies
DrByte
DrByte2y ago
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.)
N1XN
N1XNOP2y ago
@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.
cheesegrits
cheesegrits2y ago
Nope, it doesn't set any per-file attributes. Setting private just means URL's to the uploaded file get pre-signed.
N1XN
N1XNOP2y ago
Oh ok thats a pitty, is there a way I can set those custom headers per file basis?
cheesegrits
cheesegrits2y ago
I believe there is a customProperties() method you can use.
LeandroFerreira
Where is ->disk('s3') ?
DrByte
DrByte2y ago
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.
awcodes
awcodes2y ago
Do you have any console errors? Maybe the external providers permissions aren’t set up correctly too.
N1XN
N1XNOP2y ago
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!
LeandroFerreira
Did you config this?
FILAMENT_FILESYSTEM_DISK=s3
FILESYSTEM_DRIVER=s3
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
AWS_ENDPOINT=
AWS_URL=
AWS_USE_PATH_STYLE_ENDPOINT=true
FILAMENT_FILESYSTEM_DISK=s3
FILESYSTEM_DRIVER=s3
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
AWS_ENDPOINT=
AWS_URL=
AWS_USE_PATH_STYLE_ENDPOINT=true
N1XN
N1XNOP2y ago
yes I did, as the upload works as expected.
cheesegrits
cheesegrits2y ago
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.

Did you find this page helpful?