From f313ce13b4baef7c98de79336248a1046880f907 Mon Sep 17 00:00:00 2001 From: Dimitri Sitchet Tomkeu Date: Sun, 6 Sep 2026 04:50:56 +0100 Subject: [PATCH] =?UTF-8?q?feat(ResponseTrait):=20am=C3=A9lioration=20des?= =?UTF-8?q?=20m=C3=A9thodes=20de=20t=C3=A9l=C3=A9chargement=20et=20de=20st?= =?UTF-8?q?reaming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/Concerns/ResponseTrait.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Http/Concerns/ResponseTrait.php b/src/Http/Concerns/ResponseTrait.php index 34795d19..9204231d 100644 --- a/src/Http/Concerns/ResponseTrait.php +++ b/src/Http/Concerns/ResponseTrait.php @@ -176,12 +176,20 @@ public function download(SplFileInfo|string $file, ?string $name = null, array $ * Créez une nouvelle instance de réponse diffusée en continu sous forme de téléchargement de fichier. */ public function streamDownload(callable|StreamInterface|string $stream, string $name, array $headers = []): static + { + return $this->stream($stream, $name, $headers)->withDownload($name); + } + + /** + * Créez une nouvelle instance de réponse diffusée en continu. + */ + public function stream(callable|StreamInterface|string $stream, string $name, array $headers = []): static { if (! ($stream instanceof StreamInterface)) { - $stream = to_stream($stream); + $stream = Utils::streamFor($stream); } - return $this->withHeaders($headers)->withBody($stream)->withType(pathinfo($name, PATHINFO_EXTENSION))->withDownload($name); + return $this->withHeaders($headers)->withBody($stream)->withType(pathinfo($name, PATHINFO_EXTENSION)); } /**