예제 #1
0
 /**
  * Generates the download data
  *
  * @param int $fileId the ID of the file of which we need a large preview of
  * @param string|null $filename
  *
  * @return array|false
  */
 private function getDownload($fileId, $filename)
 {
     /** @type File $file */
     $file = $this->downloadService->getResourceFromId($fileId);
     $this->configService->validateMimeType($file->getMimeType());
     $download = $this->downloadService->downloadFile($file);
     if (is_null($filename)) {
         $filename = $file->getName();
     }
     $download['name'] = $filename;
     return $download;
 }
예제 #2
0
 /**
  * @param File $file
  * @param bool $animatedPreview
  * @param int $width
  * @param int $height
  * @param bool $keepAspect
  * @param bool $base64Encode
  *
  * @return array
  */
 private function getPreviewData($file, $animatedPreview, $width, $height, $keepAspect, $base64Encode)
 {
     $status = Http::STATUS_OK;
     if ($this->previewService->isPreviewRequired($file, $animatedPreview)) {
         $preview = $this->previewService->createPreview($file, $width, $height, $keepAspect, $base64Encode);
     } else {
         $preview = $this->downloadService->downloadFile($file, $base64Encode);
     }
     if (!$preview) {
         list($preview, $status) = $this->getErrorData();
     }
     return [$preview, $status];
 }
 /**
  * @expectedException \OCA\Gallery\Service\NotFoundServiceException
  */
 public function testDownloadNonExistentFile()
 {
     $file = $this->mockBadFile(12345);
     $this->service->downloadFile($file);
 }
 /**
  * @param $file
  * @param $base64Encode
  * @param $preview
  */
 private function mockDownloadFile($file, $base64Encode, $preview)
 {
     $this->downloadService->expects($this->once())->method('downloadFile')->with($this->equalTo($file), $this->equalTo($base64Encode))->willReturn($preview);
 }
 /**
  * Mocks DownloadService->downloadFile
  *
  * @param object|\PHPUnit_Framework_MockObject_MockObject $file
  * @param array $download
  */
 private function mockDownloadFile($file, $download)
 {
     $this->downloadService->expects($this->once())->method('downloadFile')->with($this->equalTo($file))->willReturn($download);
 }