F
Filament5mo ago
Marcel

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();
});
2 Replies
Marcel
MarcelOP5mo ago
GitHub
How can I use $set() to set an existing file in a FileUpload form c...
Component FileUpload::make($this->getInputName('avatar')) ->avatar() ->alignCenter() ->columnSpanFull() Trying to set avatar URL private function setData(Customer $customer, Get...
Marcel
MarcelOP5mo ago
GitHub
File upload file from external file url · filamentphp filament · Di...
Package Form builder Package Version V3.2.92 How can we help you? I'm trying to set the fileupload to an external file url. This is what I tried: Action::make('crawl') ->icon('he...
Want results from more Discord servers?
Add your server