public function storeBytes($bytes, array $extra = [], array $options = [])
    {
        $this->createChunksIndex();

        $record = $extra + [
            'length' => mb_strlen($bytes, '8bit'),
            'md5' => md5($bytes),
        ];

        try {
            $file = $this->insertFile($record, $options);
        } catch (MongoException $e) {
            throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), $e->getCode(), $e);
        }

        try {
            $this->insertChunksFromBytes($bytes, $file);
        } catch (MongoException $e) {
            $this->delete($file['_id']);
            throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), $e->getCode(), $e);
        }

        return $file['_id'];
    }
public function storeBytes($bytes, array $extra = [], array $options = [])
    {
        $this->createChunksIndex();

        $record = $extra + [
            'length' => mb_strlen($bytes, '8bit'),
            'md5' => md5($bytes),
        ];

        try {
            $file = $this->insertFile($record, $options);
        } catch (MongoException $e) {
            throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), $e->getCode(), $e);
        }

        try {
            $this->insertChunksFromBytes($bytes, $file);
        } catch (MongoException $e) {
            $this->delete($file['_id']);
            throw new MongoGridFSException('Could not store file: ' . $e->getMessage(), $e->getCode(), $e);
        }

        return $file['_id'];
    }
public function storeBytes ( $ bytes , array $ extra = [ ] , array $ options = [ ] ) { $ this -> createChunksIndex ( ) ; $ record = $ extra + [ 'length' => mb_strlen ( $ bytes , '8bit' ) , 'md5' => md5 ( $ bytes ) , ] ; try { $ file = $ this -> insertFile ( $ record , $ options ) ; } catch ( MongoException $ e ) { throw new MongoGridFSException ( 'Could not store file: ' . $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } try { $ this -> insertChunksFromBytes ( $ bytes , $ file ) ; } catch ( MongoException $ e ) { $ this -> delete ( $ file [ '_id' ] ) ; throw new MongoGridFSException ( 'Could not store file: ' . $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } return $ file [ '_id' ] ; }
Chunkifies and stores bytes in the database
@link http://php.net/manual/en/mongogridfs.storebytes.php
@param string $bytes A string of bytes to store
@param array $extra Other metadata to add to the file saved
@param array $options Options for the store. "safe": Check that this store succeeded
@return mixed The _id of the object saved
Chunkifies and stores bytes in the database