Filament Export Action

Hi, I have this code for exporting it still work in Laravel 10 and Filament v3.2, but now I tried the same code in Laravel 11 Filament v3.2, it doesn't work. I see the problem doesn't create a filament_exports folder in public/storage. ExportAction::make() ->label('تصدير') ->color('red') ->icon('heroicon-o-arrow-down-tray') ->exporter(ContactExporter::class) ->formats([ ExportFormat::Xlsx, ]) ->fileName(fn (Export $export): string => "تصدير المساهمين-{$export->getKey()}") ->after(function () { $id = Export::latest()?->first()?->id; $path = 'filament_exports/' . $id . '/تصدير المساهمين-' . $id . '.xlsx'; // you can change the filename based on the Exporter if (Storage::disk('public')->exists($path)) { return response()->stream( function () use ($path, $id) { $stream = Storage::disk('public')->readStream($path); dd($stream); fpassthru($stream); fclose($stream); Storage::disk('public')->deleteDirectory('filament_exports/' . $id); Export::truncate(); }, 200, [ 'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'Content-Disposition' => 'attachment; filename=' . $id . '.xlsx', ] ); } else { abort(404, 'الملف غير موجود.'); } }) Any solution please?
7 Replies
lukevi
lukevi3mo ago
You might test in just a basic non-filament route whether you can create that dir & write a file there, using your same Storage disk. If you can't, that would point to your storage config..
krekas
krekas3mo ago
run queue:listen maybe?
abdullafahem
abdullafahem3mo ago
The same code run well in Laravel 10 with Filament v3.2 another app in this new app that I created how it is possible? Does not create the filament_exports folder in storage. Also run well with non-filament route I can create/write that public dir. Same issue nothing change
lukevi
lukevi3mo ago
right- I don't know the exact problem, but testing the same Storage() method in plain Laravel will surely narrow down where your issue is. My guess is it's in the plain Laravel side, not FIlament.
abdullafahem
abdullafahem3mo ago
Maybe because I tried with Laravel 10 it works well only in Laravel 11
lukevi
lukevi3mo ago
Also run well with non-filament route I can create/write that public dir.
ah sorry, I didn't see this part. also just noticed that you're instantly starting the download for the user - that is clever. I don't have any other good suggestions. One thing to try might be a more basic path with just A-Z?
abdullafahem
abdullafahem3mo ago
I change it in Laravel 10 I didn't have time for, so thank you for your help.