How to Access image in filament if I want to modify that .

How to Access image in filament if I want to modify that like I am trying to upload image on BunnyCDN and CDN's path want to update in DB, I dont want to upload image in local disk I created disk in FileSystem.php
'bunnycdn' => [
'driver' => 'bunnycdn',
'storage_zone' => env('BUNNYCDN_STORAGE_ZONE'),
'api_key' => env('BUNNYCDN_APY_KEY'),
'region' => env('BUNNYCDN_REGION'),
'public_url'=>env('BUNNY_PUBLIC_URL')
],
'bunnycdn' => [
'driver' => 'bunnycdn',
'storage_zone' => env('BUNNYCDN_STORAGE_ZONE'),
'api_key' => env('BUNNYCDN_APY_KEY'),
'region' => env('BUNNYCDN_REGION'),
'public_url'=>env('BUNNY_PUBLIC_URL')
],
AppServicePRovider
public function boot(): void
{
Storage::extend('bunnycdn', function ($app, $config) {
$adapter = new BunnyCDNAdapter(
new BunnyCDNClient(
$config['storage_zone'],
$config['api_key'],
$config['region']
),
'https://ape-stegback-tj.b-cdn.net/development' # Optional
);

return new FilesystemAdapter(
new Filesystem($adapter, $config),
$adapter,
$config
);
});
}
public function boot(): void
{
Storage::extend('bunnycdn', function ($app, $config) {
$adapter = new BunnyCDNAdapter(
new BunnyCDNClient(
$config['storage_zone'],
$config['api_key'],
$config['region']
),
'https://ape-stegback-tj.b-cdn.net/development' # Optional
);

return new FilesystemAdapter(
new Filesystem($adapter, $config),
$adapter,
$config
);
});
}
CreateRecord
public function mutateFormDataBeforeCreate($data): array
{
if (request()->hasFile('phone')) {
$phoneFile = request()->file('phone');
$fileName = $phoneFile->hashName();
$filePath = "eppsolar/slider/{$fileName}";
dd($filePath);
Storage::disk('bunnycdn')->put($filePath, file_get_contents($phoneFile));
$data['phone'] = Storage::disk('bunnycdn')->url($filePath);
}
}
public function mutateFormDataBeforeCreate($data): array
{
if (request()->hasFile('phone')) {
$phoneFile = request()->file('phone');
$fileName = $phoneFile->hashName();
$filePath = "eppsolar/slider/{$fileName}";
dd($filePath);
Storage::disk('bunnycdn')->put($filePath, file_get_contents($phoneFile));
$data['phone'] = Storage::disk('bunnycdn')->url($filePath);
}
}
4 Replies
toeknee
toeknee8mo ago
Laravel
File Uploads | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
kartikey_maandothiya
I am not uploading on livewire. I am uploading via Filament Admin Panel
toeknee
toeknee8mo ago
And what does Filament Admin Panel Use.....
kartikey_maandothiya
obviously I know but the document you shared is only work with default functionality on livewire and filamnet work differently and its data processing functionality is also different , and the core function of filament muteFormDataBeforeSave here we modify the data and I want to upload images from here to bunnyCDN Also I used the Disk() but its not working check my code flow.
Want results from more Discord servers?
Add your server