/** * Download an archived file * * @param int $id * @param string $archiver * @param string $key * * @return StreamedResponse */ public function downloadFilesAction($id, $archiver, $key) { $jobExecution = $this->findOr404('Akeneo\\Component\\Batch\\Model\\JobExecution', $id); $this->eventDispatcher->dispatch(JobExecutionEvents::PRE_DOWNLOAD_FILES, new GenericEvent($jobExecution)); $stream = $this->archivist->getArchive($jobExecution, $archiver, $key); return new StreamedFileResponse($stream); }
/** * Download an archived file * * @param int $id * @param string $archiver * @param string $key * * @return StreamedResponse */ public function downloadFilesAction($id, $archiver, $key) { $jobExecution = $this->jobExecutionRepo->find($id); if (null === $jobExecution) { throw new NotFoundHttpException('Akeneo\\Component\\Batch\\Model\\JobExecution entity not found'); } $this->eventDispatcher->dispatch(JobExecutionEvents::PRE_DOWNLOAD_FILES, new GenericEvent($jobExecution)); $stream = $this->archivist->getArchive($jobExecution, $archiver, $key); return new StreamedFileResponse($stream); }
/** * Download an archived file * * @param int $id * @param string $archiver * @param string $key * * @return StreamedResponse */ public function downloadFilesAction($id, $archiver, $key) { $jobExecution = $this->findOr404('AkeneoBatchBundle:JobExecution', $id); $this->eventDispatcher->dispatch(JobExecutionEvents::PRE_DOWNLOAD_FILES, new GenericEvent($jobExecution)); $stream = $this->archivist->getArchive($jobExecution, $archiver, $key); return new StreamedResponse(function () use($stream) { $stream->open(new StreamMode('rb')); while (!$stream->eof()) { echo $stream->read(self::BLOCK_SIZE); } $stream->close(); }, 200, ['Content-Type' => 'application/octet-stream']); }
public function testSubscribedEvents() { $this->assertEquals(array(EventInterface::BEFORE_JOB_STATUS_UPGRADE => 'beforeStatusUpgrade'), JobExecutionArchivist::getSubscribedEvents()); }