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();