本文整理汇总了PHP中Symfony\Component\HttpFoundation\BinaryFileResponse::getFile方法的典型用法代码示例。如果您正苦于以下问题:PHP BinaryFileResponse::getFile方法的具体用法?PHP BinaryFileResponse::getFile怎么用?PHP BinaryFileResponse::getFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\BinaryFileResponse
的用法示例。
在下文中一共展示了BinaryFileResponse::getFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testConstructWithNonAsciiFilename
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());
}
示例2: getPdfContent
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 '';
}
示例3: testSplFileObject
public function testSplFileObject()
{
$filePath = __DIR__ . '/File/Fixtures/test';
$file = new \SplFileObject($filePath);
$response = new BinaryFileResponse($file);
$this->assertEquals(realpath($response->getFile()->getPathname()), realpath($filePath));
}
示例4: file
/**
* 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;
}