Phalcon\Db\Adapter\MongoDB\GridFS\CollectionWrapper::getChunksIteratorByFilesId PHP Method

getChunksIteratorByFilesId() public method

Returns a chunks iterator for a given file ID.
    public function getChunksIteratorByFilesId($id)
    {
        $cursor = $this->chunksCollection->find(['files_id' => $id], ['sort' => ['n' => 1], 'typeMap' => ['root' => 'stdClass']]);
        return new IteratorIterator($cursor);
    }

Usage Example

Beispiel #1
0
 /**
  * Constructs a readable GridFS stream.
  *
  * @param CollectionWrapper $collectionWrapper GridFS collection wrapper
  * @param stdClass          $file GridFS file document
  *
  * @throws CorruptFileException
  */
 public function __construct(CollectionWrapper $collectionWrapper, stdClass $file)
 {
     $this->file = $file;
     $this->chunksIterator = $collectionWrapper->getChunksIteratorByFilesId($this->file->_id);
     $this->numChunks = $file->length >= 0 ? ceil($file->length / $file->chunkSize) : 0;
     $this->initEmptyBuffer();
 }