* Create a response that downloads the given file via a stream.
* Has the option to delete the provided file once the stream is closed.
*/
- public function streamedFileDirectly(string $filePath, string $fileName, int $fileSize, bool $deleteAfter = false): StreamedResponse
+ public function streamedFileDirectly(string $filePath, string $fileName, bool $deleteAfter = false): StreamedResponse
{
+ $fileSize = filesize($filePath);
$stream = fopen($filePath, 'r');
if ($deleteAfter) {
);
}
+ /**
+ * Create a response that provides the given file via a stream with detected content-type.
+ * Has the option to delete the provided file once the stream is closed.
+ */
+ public function streamedFileInline(string $filePath, ?string $fileName = null): StreamedResponse
+ {
+ $fileSize = filesize($filePath);
+ $stream = fopen($filePath, 'r');
+
+ if ($fileName === null) {
+ $fileName = basename($filePath);
+ }
+
+ return $this->streamedInline($stream, $fileName, $fileSize);
+ }
+
/**
* Get the common headers to provide for a download response.
*/