From 162688ceb49810a0be12e542602b0b32ea6abbab Mon Sep 17 00:00:00 2001 From: Maxime Renou Date: Wed, 7 Jan 2026 12:33:08 +0100 Subject: [PATCH] fix file download --- src/Entity/Action.php | 7 ++++--- src/Laravel/PilotServiceProvider.php | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Entity/Action.php b/src/Entity/Action.php index ea550ec..abb4079 100644 --- a/src/Entity/Action.php +++ b/src/Entity/Action.php @@ -23,12 +23,13 @@ abstract class Action extends Entity } public function file( - string $contents, + string $path, string $name = '', - string $type = '' + string $type = '', + bool $deleteAfterDownload = false, ) { return [ - 'file' => compact('contents', 'name', 'type'), + 'file' => compact('path', 'name', 'type', 'deleteAfterDownload'), ]; } diff --git a/src/Laravel/PilotServiceProvider.php b/src/Laravel/PilotServiceProvider.php index 41dc8cc..04c9828 100644 --- a/src/Laravel/PilotServiceProvider.php +++ b/src/Laravel/PilotServiceProvider.php @@ -96,12 +96,12 @@ class PilotServiceProvider extends ServiceProvider if (isset($output['file'])) { return response()->download( - $output['file']['contents'], - $output['file']['name'], - [ + $output['file']['path'], + $output['file']['name'] ?? null, + ! empty($output['file']['type']) ? [ 'Content-Type' => $output['file']['type'], - ] - ); + ] : [] + )->deleteFileAfterSend(isset($output['file']['deleteAfterDownload']) ? $output['file']['deleteAfterDownload'] : false); } return response();