storeFile() public method

Create file in GridFS from file in filesystem
public storeFile ( string $filename, array $metadata = [] ) : MongoId
$filename string name of source file
$metadata array metadata stored with file
return MongoId Id of stored file
Example #1
0
 public function testCreateFromFile()
 {
     // create temp file
     $filename = tempnam(sys_get_temp_dir(), 'prefix');
     file_put_contents($filename, 'somebinarydata');
     // store file
     $id = $this->gridFs->storeFile($filename, array('meta1' => 1, 'meta2' => 2));
     $this->assertInstanceOf('\\MongoId', $id);
     unlink($filename);
 }