Skip to content

How to store blob image in database #13687

Closed Answered by pluma
PrasadChinwal asked this question in Help
Discussion options

You must be logged in to vote

There doesn't seem to be an easy way to do this with the built-in image field as it is built around the laravel disk drivers.

I was able to trick filament into storing the uploade file as a data URI in the field by doing the following:

In the form I modified the field like so:

Forms\FileUpload::make($yourFileFieldNameHere)
    ->disk('fake')
    ->getUploadedFileNameForStorageUsing(
        fn(TemporaryUploadedFile $file): string => 'data:' . $file->getMimeType() . ';base64,' . base64_encode($file->getContent())
    )

Then I added the following to the disks entry in config/filesystems.php:

        'fake' => [
            'driver' => 'fake',
        ],

I also registered the fake storage in…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@josuanbn
Comment options

Answer selected by PrasadChinwal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants