F
Filamentβ€’11mo ago
SirAlyon

Error in Filament's ImportAction Feature

Hello everyone! I'm encountering an issue with Filament's new ImportAction feature, and I've updated Filament to version 3.1 to utilize this functionality. I've generated a test importer using the automatic class generation. Everything appears to be functioning correctly until I attempt to upload a file. After the upload, I encounter the following error:
fgetcsv(): Read of 8192 bytes failed with errno=21 Is a directory.
fgetcsv(): Read of 8192 bytes failed with errno=21 Is a directory.
I'm unsure about where to begin debugging this error. Any advice or insights would be greatly appreciated. Below is the relevant code snippet: My Resource:
public static function table(Table $table): Table
{
return $table
->headerActions([
ImportAction::make()
->importer(KiidMailPdfImporter::class)
])
...other code
}
public static function table(Table $table): Table
{
return $table
->headerActions([
ImportAction::make()
->importer(KiidMailPdfImporter::class)
])
...other code
}
My Importer:
namespace App\Filament\Imports;

use App\Models\KiidMailPdf;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;

class KiidMailPdfImporter extends Importer
{
protected static ?string $model = KiidMailPdf::class;

public static function getColumns(): array
{
return [
ImportColumn::make('cstato')
->rules(['max:1']),
ImportColumn::make('tuts')
->rules(['datetime']),
ImportColumn::make('cisin')
->rules(['max:50']),

...other ImportColumn
];
}

...other generated code
namespace App\Filament\Imports;

use App\Models\KiidMailPdf;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;

class KiidMailPdfImporter extends Importer
{
protected static ?string $model = KiidMailPdf::class;

public static function getColumns(): array
{
return [
ImportColumn::make('cstato')
->rules(['max:1']),
ImportColumn::make('tuts')
->rules(['datetime']),
ImportColumn::make('cisin')
->rules(['max:50']),

...other ImportColumn
];
}

...other generated code
Thank you.. πŸ™‚
7 Replies
SirAlyon
SirAlyonOPβ€’11mo ago
It works until i try to drop in a file:
No description
SirAlyon
SirAlyonOPβ€’11mo ago
Then...
No description
krekas
krekasβ€’11mo ago
google your error message
SirAlyon
SirAlyonOPβ€’11mo ago
Hi, i already did i coudn't find any solution
krekas
krekasβ€’11mo ago
From the docs: Any rows that do not pass validation will not be imported. Instead, they will be compiled into a new CSV of "failed rows", which the user can download after the import has finished. The user will be shown a list of validation errors for each row that failed.
SirAlyon
SirAlyonOPβ€’11mo ago
Thanks for the input. I'm trying to fix this error, but i can'0t understand why it is working on my production machine and is not on the dev one. Machines have the same dependencies versions and code, i can't really understand why it is not working on the second one. (the error is the same of the post) I found what was creating the issue: had to fix the permissions on the livewire tmp folder, laravel coudn't write in it. Maybe it will help other users. Bye guys! W filament πŸ™‚
Want results from more Discord servers?
Add your server