/** * * 从gridfs直接输出到客户端 */ public function output() { /* * Mongo方式 $grid=$this->getGridFS(); $cursor = $grid->chunks->find(array('files_id' => $id))->sort(array('n' => 1)); foreach($cursor as $chunk) { echo $chunk['data']->bin; } */ //$bin = fastdfs_storage_download_file_to_buff($this->fs_group_name, $this->fs_filename); $bin = NDCS::download_file_to_buff($this->fs_group_name, $this->fs_filename); if (strlen($bin) > 0) { Core::header('Content-Type: ' . $this->mime); Core::header('Content-Length: ' . strlen($bin)); echo $bin; Core::quit(); } else { GridFS::fdfs_error($this->fs_group_name, $this->fs_filename); } }
public function sort() { /* $this->chunk=0; $this->chunks_num=ceil($this->parent->length/$this->_chunksize); $chunk=array('data'=>$this); $cursor=array(); for($i=0;$i<$this->chunks_num;$i++){ $cursor[]=$chunk; } */ // $fs_group_name = $this->parent->fs_group_name; // $fs_filename = $this->parent->fs_filename; // $file_offset = 0; //对象方式 // $this->bin = self::$fdfs->storage_download_file_to_buff($fs_group_name, $fs_filename, $file_offset, $this->_chunksize); //$this->bin = fastdfs_storage_download_file_to_buff($this->parent->fs_group_name, $this->parent->fs_filename); $this->bin = NDCS::download_file_to_buff($this->parent->fs_group_name, $this->parent->fs_filename); if (strlen($this->bin) > 0) { $chunk = array('data' => $this); $cursor[] = $chunk; return $cursor; } else { self::fdfs_error(); } }