getResource() public method

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
return resource Returns a resource that can be used to read the file with
Ejemplo n.º 1
0
Archivo: File.php Proyecto: im286er/ent
 /**
  * 显示/下载资源信息
  *
  * @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();
     }
 }
Ejemplo n.º 2
0
 public function getResource()
 {
     return $this->file->getResource();
 }