Cant download xlsx in vapor through Export action

Currently CSV files are downloading fine but XLSX are throwing {"message":"Internal Server Error"} in Vapor
6 Replies
Stefano
Stefano6mo ago
Did you ever solve this? Having the same issue it seems to work locally (using minio to store files)
Stefano
Stefano6mo ago
I could narrow it down to Filament\Actions\Exports\Downloaders\XlsxDownloader the issue seems to be
if ($disk->exists($filePath = $directory . DIRECTORY_SEPARATOR . $fileName)) {
return $disk->download($filePath);
}
if ($disk->exists($filePath = $directory . DIRECTORY_SEPARATOR . $fileName)) {
return $disk->download($filePath);
}
the download method is having issues with the lambda runtime. I would guess this is what I am talking about: https://docs.vapor.build/projects/development.html#binary-responses if I delete the file, the streamed response kicks in (building the file inside the stream from the CSV data), which works just fine. Unfortunately there doesnt seem to be a way to keep the xlsx download button but disable its generation (I wouldnt even call this correct)
Development | Laravel Vapor
Laravel at Infinite Scale
bwurtz999
bwurtz9992mo ago
@Stefano Were you ever able to solve this? I am having the same issue. XLSX works perfectly in local development, throws an error in Vapor. I get a 502 Bad Gateway error when trying to download the document
Stefano
Stefano2mo ago
unfortunately no, I had to settle for the .csv format... if I had to go any further I would've tried to hook myself somewhere and add the X-Vapor-Base64-Encode header to true, but I did not see any obvious way to do so at the time
bwurtz999
bwurtz9992mo ago
Appreciate the response. I'm sticking with CSV as well
Ron
Ron2mo ago
@bwurtz999 @Stefano Thanks for the investigation here. I was able to get this to work , but maybe not in the cleanest way but I can live with it to have the functionality. 1. Make a derivative copy of XlsxDownloader to my App namespace I copied \Filament\Actions\Exports\Downloaders\XlsxDownloader.php to App\Filament\Actions\Exports\Downloaders\XlsxDownloader.php 2. Setup AppServiceProvider Bindings
$this->app->bind(XlsxDownloader::class, function () {
return new \App\Filament\Actions\Exports\Downloaders\XlsxDownloader;
});
$this->app->bind(XlsxDownloader::class, function () {
return new \App\Filament\Actions\Exports\Downloaders\XlsxDownloader;
});
3. Set the header on the download call from the storage disk
if ($disk->exists($filePath = $directory.DIRECTORY_SEPARATOR.$fileName)) {

return $disk->download(path: $filePath, name: null, headers: [
'X-Vapor-Base64-Encode' => 'True',
]);
}
if ($disk->exists($filePath = $directory.DIRECTORY_SEPARATOR.$fileName)) {

return $disk->download(path: $filePath, name: null, headers: [
'X-Vapor-Base64-Encode' => 'True',
]);
}
Want results from more Discord servers?
Add your server