File upload file from external file url
I'm trying to set the fileupload to an external file url.
This is what I tried:
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();
});