Problems to upload file to S3
Hello Guys.
I'm trying to upload a file to S3 using Filament FileUpload component. It upload to S3 in a tmp folder (livewire-tmp) and when i hit "Save changes" in filament, its disappears from the tmp folder and write the filename to db (ex: ["01J3RFMJWTXCF4B7VYKP098M1Y.webp", "01J3RFR9CNAX9SSX3ECHGX9K6Y.webp"].) and the UploadFile component updates and not show the uploaded images.
Searching inside the S3 Bucket, i do not have any file inside :/
Someone pass through this problem yet? Thanks for any help! 🙂
4 Replies
Hello Patrick, could you please share the relevant code to help diagnose this issue?
Solution
S3 requires setting the visibilty() to private to upload.
@Patrick Jean here's a snippet from my project. This is for uploading an attachment for a particular record, so I wanted it stored in a "directory" ( i.e. key prefix ) by the record id:
Forms\Components\FileUpload::make('file_path_attribute')
->disk('s3_disk_name')
->directory( function( $livewire ): string {
return 'your_path_prefix/' . $livewire->record->id;
})
->visibility('private')
thanks for help guys, i will test these suggestions later! i didn’t know about the visibility, maybe that’s the problem, i’m setting to public 😖
Guys, worked with the visibility private! Thanks so much! 😄