Create file in GridFS from binary data
public storeBytes ( string $bytes, array $metadata = [] ) : MongoId | ||
$bytes | string | binary data to store in GridFS |
$metadata | array | metadata stored with file |
return | MongoId | Id of stored file |
public function testGetResource() { $id = $this->gridFs->storeBytes('somebinarydata', array('meta' => 1)); $this->assertTrue(is_resource($this->gridFs->getFileById($id)->getResource())); }
public function testGetMd5Checksum() { $id = $this->gridFs->storeBytes('somebinarydata'); $file = $this->gridFs->getFileById($id); $this->assertEquals(md5('somebinarydata'), $file->getMd5Checksum()); }