/** * Sends the file. */ public function sendContent() { if (!$this->isSuccessful()) { parent::sendContent(); return; } $outStream = fopen('php://output', 'wb'); $fileStream = $this->file->readStream(); stream_copy_to_stream($fileStream, $outStream); fclose($outStream); fclose($fileStream); }
public function testFileReadStream() { $prophecy = $this->prophesize('League\\Flysystem\\FilesystemInterface'); $prophecy->readStream('path.txt')->willReturn('contents'); $filesystem = $prophecy->reveal(); $file = new File(null, 'path.txt'); $file->setFilesystem($filesystem); $output = $file->readStream(); $this->assertEquals('contents', $output); }
protected function createResponseForFile(File $file) { return new StreamedResponse(function () use($file) { fpassthru($file->readStream()); }, Response::HTTP_OK, array('Content-Type' => $file->getMimetype())); }
/** * Process an image using the provided template * * @param File $file The file handler for the image * @param ImageManager $imageManager The image manipulation manager * @param TemplateInterface $template The template * @return Image The processed image */ private function processImage(File $file, ImageManager $imageManager, TemplateInterface $template) { // Process the image using the template $image = new \Diarmuidie\ImageRack\Image\Process($file->readStream(), $imageManager); // Process the image return $image->process($template); }