Inheritance: implements eZ\Publish\Core\IO\IOServiceInterface
 /**
  * @param mixed $contentId ID of a valid Content
  * @param string $fieldIdentifier Field Definition identifier of the Field the file must be downloaded from
  * @param string $filename
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \eZ\Bundle\EzPublishIOBundle\BinaryStreamResponse
  */
 public function downloadBinaryFileAction($contentId, $fieldIdentifier, $filename, Request $request)
 {
     if ($request->query->has('version')) {
         $content = $this->contentService->loadContent($contentId, null, $request->query->get('version'));
     } else {
         $content = $this->contentService->loadContent($contentId);
     }
     $field = $this->translationHelper->getTranslatedField($content, $fieldIdentifier, $request->query->has('inLanguage') ? $request->query->get('inLanguage') : null);
     if (!$field instanceof Field) {
         throw new InvalidArgumentException("'{$fieldIdentifier}' field not present on content #{$content->contentInfo->id} '{$content->contentInfo->name}'");
     }
     $response = new BinaryStreamResponse($this->ioService->loadBinaryFile($field->value->id), $this->ioService);
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename);
     return $response;
 }
 /**
  * @covers \eZ\Publish\Core\IO\IOService::createBinaryFile
  * @covers \eZ\Publish\Core\IO\IOService::buildSPIBinaryFileCreateStructObject
  * @covers \eZ\Publish\Core\IO\IOService::buildDomainBinaryFileObject
  * @depends testNewBinaryCreateStructFromLocalFile
  */
 public function testCreateBinaryFile(BinaryFileCreateStruct $createStruct)
 {
     $createStruct->id = "my/path.php";
     $id = $this->getPrefixedUri($createStruct->id);
     $spiBinaryFile = new SPIBinaryFile();
     $spiBinaryFile->id = $id;
     $spiBinaryFile->uri = $id;
     $spiBinaryFile->size = filesize(__FILE__);
     $spiBinaryFile->mimeType = 'text/x-php';
     $this->binarydataHandlerMock->expects($this->once())->method('create')->with($this->callback(function ($subject) use($id) {
         if (!$subject instanceof \eZ\Publish\SPI\IO\BinaryFileCreateStruct) {
             return false;
         }
         return $subject->id == $id;
     }));
     $this->metadataHandlerMock->expects($this->once())->method('create')->with($this->callback($this->getSPIBinaryFileCreateStructCallback($id)))->will($this->returnValue($spiBinaryFile));
     $binaryFile = $this->IOService->createBinaryFile($createStruct);
     self::assertInstanceOf('eZ\\Publish\\Core\\IO\\Values\\BinaryFile', $binaryFile);
     self::assertEquals($createStruct->id, $binaryFile->id);
     self::assertEquals($createStruct->size, $binaryFile->size);
     return $binaryFile;
 }
 public function getBinaryFileFieldTypeProcessor(IOService $binaryFileIOService)
 {
     $urlPrefix = isset($this->request) ? $this->request->getUriForPath('/') : '';
     return new FieldTypeProcessor\BinaryProcessor(sys_get_temp_dir(), $urlPrefix . $binaryFileIOService->getInternalPath('{path}'));
 }