/** * Returns the file size * GetSize wrapper of MongoGridFSFile function * @return integer file size or False on error. * @since v1.3 */ public function getSize() { Yii::trace('Trace: ' . __CLASS__ . '::' . __FUNCTION__ . '()', 'ext.MongoDb.EMongoGridFS'); if (method_exists($this->_gridFSFile, 'getSize') === true) { return $this->_gridFSFile->getSize(); } else { return false; } }
/** * Gets the size of this file. * * @return integer $size */ public function getSize() { if ($this->isDirty && $this->bytes) { return strlen($this->bytes); } if ($this->isDirty && $this->filename) { return filesize($this->filename); } if ($this->mongoGridFSFile instanceof \MongoGridFSFile) { return $this->mongoGridFSFile->getSize(); } return 0; }
public function testWrite() { $bytes = $this->object->write('tests/anotherfile'); $this->assertEquals($bytes, 129); $this->assertEquals(filesize('tests/anotherfile'), $this->object->getSize()); }
public function testGridFSProps() { $m = new Mongo(); $grid = $m->foo->getGridFS(); $x = new MongoGridFSFile($grid, array()); $this->assertNull($x->getFilename()); $this->assertNull($x->getSize()); }
/** * @param \MongoGridFS $gridFs * @param \MongoGridFSFile $file */ function it_should_rename_file($gridFs, $file) { $file->getBytes()->willReturn('some content'); $file->getSize()->willReturn(12); $gridFs->findOne('otherFilename', array())->willReturn(null); $gridFs->findOne('filename', array())->shouldBeCalled()->willReturn($file); $gridFs->storeBytes('some content', array('date' => 1234, 'filename' => 'otherFilename'))->shouldBeCalled()->willReturn('someId'); $fileToDelete = new \stdClass(); $fileToDelete->file = array('_id' => 123); $gridFs->findOne('filename', array('_id'))->willReturn($fileToDelete); $gridFs->findOne(array('_id' => 'someId'))->willReturn($file); $gridFs->delete(123)->shouldBeCalled()->willReturn(true); $this->setMetadata('otherFilename', array('date' => 1234)); $this->rename('filename', 'otherFilename')->shouldReturn(true); }
protected function format_stat(MongoGridFSFile $file) { return array("name" => $file->getFilename(), "size" => $file->getSize(), "ts" => $file->file['uploadDate']->sec, "mime" => $file->file['metadata']['mime'], "read" => true, "write" => true, "width" => $file->file['metadata']['width'], "height" => $file->file['metadata']['height']); }
public function count() { return $this->file->getSize(); }