Marcel
Marcel
FFilament
Created by Marcel on 7/3/2024 in #❓┊help
File upload file from external file url
I'm trying to set the fileupload to an external file url. This is what I tried:
Action::make('crawl')
->icon('heroicon-o-arrow-path')
->color('warning')
->size(ActionSize::Small)
->hidden(fn ($record) => !$record)
->requiresConfirmation()
->action(function($record, $livewire, Set $set) {
$data = new Crawl('https://url-to-api')->getData();

// Set image
$record->image = $data['image_url'];
$set('image', $data['image_url']);

Storage::put('name.jpg', file_get_contents($data['image_url']);
$local_path_to_image = Storage::get('name.jpg');
$image = TemporaryUploadedFile::createFromLivewire($local_path_to_image);
$set('image', [$image]);

$record->save();
});
Action::make('crawl')
->icon('heroicon-o-arrow-path')
->color('warning')
->size(ActionSize::Small)
->hidden(fn ($record) => !$record)
->requiresConfirmation()
->action(function($record, $livewire, Set $set) {
$data = new Crawl('https://url-to-api')->getData();

// Set image
$record->image = $data['image_url'];
$set('image', $data['image_url']);

Storage::put('name.jpg', file_get_contents($data['image_url']);
$local_path_to_image = Storage::get('name.jpg');
$image = TemporaryUploadedFile::createFromLivewire($local_path_to_image);
$set('image', [$image]);

$record->save();
});
3 replies
FFilament
Created by Marcel on 5/14/2024 in #❓┊help
LocaleSwitcher label of locale
No description
3 replies