/** * @dataProvider providesValidateMimeTypeWithForbiddenMimeData * * @param $mimeType * * @expectedException \OCA\GalleryPlus\Service\ForbiddenServiceException */ public function testValidateMimeTypeWithForbiddenMime($mimeType) { $supportedMimeTypes = ['image/png', 'image/jpeg', 'image/gif', 'image/x-xbitmap', 'image/bmp', 'application/postscript', 'application/x-font']; $this->assertSame($supportedMimeTypes, self::invokePrivate($this->service, 'baseMimeTypes', [$supportedMimeTypes])); $this->mockIsMimeSupported($nativeSvgSupport = true); $this->service->validateMimeType($mimeType); }
/** * 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; }
/** * Returns the file of which a preview will be generated * * @param int $fileId * * @return array<File|int|null> */ private function getFile($fileId) { $status = Http::STATUS_OK; try { /** @type File $file */ $file = $this->previewService->getResourceFromId($fileId); $this->configService->validateMimeType($file->getMimeType()); } catch (ServiceException $exception) { $file = null; $status = $this->getHttpStatusCode($exception); } return [$file, $status]; }