storeBytes() public method

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
Example #1
0
 public function testGetResource()
 {
     $id = $this->gridFs->storeBytes('somebinarydata', array('meta' => 1));
     $this->assertTrue(is_resource($this->gridFs->getFileById($id)->getResource()));
 }
Example #2
0
 public function testGetMd5Checksum()
 {
     $id = $this->gridFs->storeBytes('somebinarydata');
     $file = $this->gridFs->getFileById($id);
     $this->assertEquals(md5('somebinarydata'), $file->getMd5Checksum());
 }