- $rangeStream = new RangeSupportedStream($stream, $fileSize, $this->request->headers);
- $mime = $rangeStream->sniffMime();
+ $rangeStream = new RangeSupportedStream($stream, $fileSize, $this->request);
+ $mime = $rangeStream->sniffMime(pathinfo($fileName, PATHINFO_EXTENSION));
+ $headers = array_merge($this->getHeaders($fileName, $fileSize, $mime), $rangeStream->getResponseHeaders());
+
+ return response()->stream(
+ fn() => $rangeStream->outputAndClose(),
+ $rangeStream->getResponseStatus(),
+ $headers,
+ );
+ }
+
+ /**
+ * 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);
+ }