src/GridFS/Repository.php
public function insertOne($document, $options = [])
    {
        $objectDatas = $this->hydrator->unhydrate($document);

        $stream = $objectDatas["stream"];
        unset($objectDatas["stream"]);

        if (!isset($objectDatas["filename"])) {
            $filename = stream_get_meta_data($stream)["uri"];
        } else {
            $filename = $objectDatas["filename"];
        }

        unset($objectDatas["filename"]);

        $id = $this->bucket->uploadFromStream($filename, $stream, $objectDatas);
        $data['_id'] = $id;

        $data["stream"] = $this->bucket->openDownloadStream($data['_id']);
        $this->hydrator->hydrate($document, $data, true);

        $this->documentManager->setObjectState($document, ObjectManager::OBJ_MANAGED);
        $this->cacheObject($document);

        return true;
    }
public function insertOne($document, $options = [])
    {
        $objectDatas = $this->hydrator->unhydrate($document);

        $stream = $objectDatas["stream"];
        unset($objectDatas["stream"]);

        if (!isset($objectDatas["filename"])) {
            $filename = stream_get_meta_data($stream)["uri"];
        } else {
            $filename = $objectDatas["filename"];
        }

        unset($objectDatas["filename"]);

        $id = $this->bucket->uploadFromStream($filename, $stream, $objectDatas);
        $data['_id'] = $id;

        $data["stream"] = $this->bucket->openDownloadStream($data['_id']);
        $this->hydrator->hydrate($document, $data, true);

        $this->documentManager->setObjectState($document, ObjectManager::OBJ_MANAGED);
        $this->cacheObject($document);

        return true;
    }
public function insertOne ( $ document , $ options = [ ] ) { $ objectDatas = $ this -> hydrator -> unhydrate ( $ document ) ; $ stream = $ objectDatas [ "stream" ] ; unset ( $ objectDatas [ "stream" ] ) ; if ( ! isset ( $ objectDatas [ "filename" ] ) ) { $ filename = stream_get_meta_data ( $ stream ) [ "uri" ] ; } else { $ filename = $ objectDatas [ "filename" ] ; } unset ( $ objectDatas [ "filename" ] ) ; $ id = $ this -> bucket -> uploadFromStream ( $ filename , $ stream , $ objectDatas ) ; $ data [ '_id' ] = $ id ; $ data [ "stream" ] = $ this -> bucket -> openDownloadStream ( $ data [ '_id' ] ) ; $ this -> hydrator -> hydrate ( $ document , $ data , true ) ; $ this -> documentManager -> setObjectState ( $ document , ObjectManager :: OBJ_MANAGED ) ; $ this -> cacheObject ( $ document ) ; return true ; }
Insert a GridFS document

@param   object  $document Document to insert
@param   array   $options  Useless, just for Repository compatibility
@return  boolean
Insert a GridFS document