MongoGridFS::storeBytes

Stores a string of bytes in the database

&reftitle.description; public `mixed` `MongoGridFS::storeBytes` `string` `bytes` `array` `metadata` array() `array` `options` array()
&reftitle.parameters;

`bytes`

- String of bytes to store.

`metadata`

- Other metadata fields to include in the file document.

  &mongo.gridfs.store.metadata.note;

`options`

- Options for the store.

  &mongo.writes.parameters.writeconcern;
&reftitle.returnvalues; &mongo.gridfs.store.return;
&reftitle.errors; &mongo.errors.exceptions.writeconcern;
&reftitle.examples;

### `MongoGridFS::storeBytes` with additional metadata

    <?php
    $m = new MongoClient();
    $gridfs = $m->selectDB('test')->getGridFS();

    $bytes = 'abcdefghijklmnopqrstuvwxyz';
    $id = $gridfs->storeBytes($bytes, array('_id' => 'alphabet'));
    $gridfsFile = $gridfs->get($id);

    var_dump($gridfsFile->file);
    ?>

&example.outputs.similar;

    array(7) {
      ["_id"]=>
      string(8) "alphabet"
      ["uploadDate"]=>
      object(MongoDate)#7 (0) {
      }
      ["length"]=>
      int(26)
      ["chunkSize"]=>
      int(262144)
      ["md5"]=>
      string(32) "c3fcd3d76192e4007dfb496cca67e13b"
    }

&reftitle.seealso;

- `MongoGridFS::put`
- `MongoGridFS::storeFile`
- `MongoGridFS::storeUpload`
- MongoDB core docs on GridFS