public function testConstructWithNonAsciiFilename() { touch(sys_get_temp_dir() . '/fööö.html'); $response = new BinaryFileResponse(sys_get_temp_dir() . '/fööö.html', 200, array(), true, 'attachment'); @unlink(sys_get_temp_dir() . '/fööö.html'); $this->assertSame('fööö.html', $response->getFile()->getFilename()); }
public function getPdfContent(FileInterface $file) { if ($file != null) { if (strpos($file->getMimeType(), 'pdf') !== false) { $response = new BinaryFileResponse($this->fileService->getFilepath($file)); $text = $this->pdfToString($response->getFile()); return $text; } } return ''; }
public function testSplFileObject() { $filePath = __DIR__ . '/File/Fixtures/test'; $file = new \SplFileObject($filePath); $response = new BinaryFileResponse($file); $this->assertEquals(realpath($response->getFile()->getPathname()), realpath($filePath)); }
/** * Returns a BinaryFileResponse object with original or customized file name and disposition header. * * @param \SplFileInfo|string $file File object or path to file to be sent as response * @param string|null $fileName File name to be sent to response or null (will use original file name) * @param string $disposition Disposition of response ("attachment" is default, other type is "inline") * * @return BinaryFileResponse */ protected function file($file, $fileName = null, $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT) { $response = new BinaryFileResponse($file); $response->setContentDisposition($disposition, $fileName === null ? $response->getFile()->getFileName() : $fileName); return $response; }