public function testRead() { list($handler, $repo, $auth, $keygen) = $this->getMocks(); $resource = file_get_contents(__DIR__ . '/sample.png'); $mockFile = m::mock('Xpressengine\\Storage\\File'); $handler->shouldReceive('content')->once()->with($mockFile)->andReturn($resource); $instance = new Storage($handler, $repo, $auth, $keygen); $this->assertEquals($resource, $instance->read($mockFile)); }
/** * Extract file meta data * * @param File $file file instance * @return Meta */ protected function extractInformation(File $file) { $content = $this->storage->read($file); list($realWidth, $realHeight) = getimagesizefromstring($content); $meta = new Meta(); $meta->id = $file->getId(); $meta->originId = $file->getOriginId(false); $meta->width = $realWidth; $meta->height = $realHeight; return $meta; }
/** * Extract file meta data * * @param File $file file instance * @return Meta */ protected function extractInformation(File $file) { $meta = new Meta(); $meta->id = $file->getId(); $meta->originId = $file->getOriginId(false); $tmpPathname = $this->temp->getTempPathname(); $this->temp->createFile($tmpPathname, $this->storage->read($file)); $info = $this->reader->analyze($tmpPathname); $this->temp->remove($tmpPathname); if (isset($info['audio']['streams'])) { unset($info['audio']['streams']); } $meta->audio = $info['audio']; $meta->playtime = $info['playtime_seconds']; $meta->bitrate = $info['bitrate']; return $meta; }
public function file($id) { $file = $this->storage->get($id); header('Content-type: ' . $file->mime); echo $this->storage->read($file); }