getResource() public méthode

The contents of the file are pulled out of MongoDB on the fly, so that the whole file does not have to be loaded into memory first. At most two GridFSFile chunks will be loaded in memory.
public getResource ( ) : resource
Résultat resource Returns a resource that can be used to read the file with
Exemple #1
0
 /**
  * 显示/下载资源信息
  *
  * @param MongoGridFSFile $gridFsFile            
  */
 public function output(\MongoGridFSFile $gridFsFile, $output = true, $download = false)
 {
     $fileInfo = $gridFsFile->file;
     $fileName = $fileInfo['filename'];
     if ($output) {
         setHeaderExpires();
         if (isset($fileInfo['mime'])) {
             header('Content-Type: ' . $fileInfo['mime'] . ';');
         }
         if ($download) {
             header('Content-Disposition:attachment;filename="' . $fileName . '"');
         } else {
             header('Content-Disposition:filename="' . $fileName . '"');
         }
         $stream = $gridFsFile->getResource();
         while (!feof($stream)) {
             echo fread($stream, 8192);
         }
     } else {
         return $gridFsFile->getBytes();
     }
 }
Exemple #2
0
 public function getResource()
 {
     return $this->file->getResource();
 }