Skip to content

Instantly share code, notes, and snippets.

@rela589n
Created October 26, 2023 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rela589n/e677f31672f353919ca9a89be9961e16 to your computer and use it in GitHub Desktop.
Save rela589n/e677f31672f353919ca9a89be9961e16 to your computer and use it in GitHub Desktop.
Symfony streaming responses from the file system
return new StreamedResponse(
static fn (): int => fpassthru($photo->stream),
headers: [
'Content-Type' => $photo->mimeType,
'Content-Length' => $photo->fileSize,
'Content-Disposition' => HeaderUtils::makeDisposition(
HeaderUtils::DISPOSITION_INLINE,
$photo->baseName,
),
],
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment