/** * @param FileObject $file * @param Response $response */ protected function injectContentToResponse(FileObject $file, Response $response) { $response->setContent(function () use($file) { return file_get_contents($file->getRealPath()); }); }
/** * Returns the mimetype of a version provided by this plugin via retrieving and inspecting. * More specific plugins should override this for performance. * * @param File $file * @param Version $version * @return string */ public function getMimeType(File $file, Version $version) { $retrieved = $this->storage->retrieveVersion($this->getApplicableVersionable($file), $version); $fileObj = new FileObject($retrieved); return $fileObj->getMimeType(); }
/** * @test */ public function returnsMimeType() { $fileObj = new FileObject(ROOT_TESTS . '/data/self-lussing-manatee.jpg'); $this->assertEquals('image/jpeg', $fileObj->getMimeType()); }
/** * Deletes on destruct if temporary */ public function __destruct() { if ($this->isTemporary()) { unlink($this->fileObject->getRealPath()); } }