public function download($ftkey, $size, $passthru = FALSE)
  {
    $this->init($ftkey);

    if($passthru)
    {
      return $this->passthru($size);
    }

    $buff = new Str("");
    $size = intval($size);
    $pack = 4096;

    Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size);

    for($seek = 0;$seek < $size;)
    {
      $rest = $size-$seek;
      $pack = $rest < $pack ? $rest : $pack;
      $data = $this->getTransport()->read($rest < $pack ? $rest : $pack);
      $seek = $seek+$pack;

      $buff->append($data);

      Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size);
    }

    $this->getProfiler()->stop();

    Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size);

    if(strlen($buff) != $size)
    {
      throw new Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)");
    }

    return $buff;
  }
public function download($ftkey, $size, $passthru = FALSE)
  {
    $this->init($ftkey);

    if($passthru)
    {
      return $this->passthru($size);
    }

    $buff = new Str("");
    $size = intval($size);
    $pack = 4096;

    Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size);

    for($seek = 0;$seek < $size;)
    {
      $rest = $size-$seek;
      $pack = $rest < $pack ? $rest : $pack;
      $data = $this->getTransport()->read($rest < $pack ? $rest : $pack);
      $seek = $seek+$pack;

      $buff->append($data);

      Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size);
    }

    $this->getProfiler()->stop();

    Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size);

    if(strlen($buff) != $size)
    {
      throw new Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)");
    }

    return $buff;
  }
public function download ( $ ftkey , $ size , $ passthru = FALSE ) { $ this -> init ( $ ftkey ) ; if ( $ passthru ) { return $ this -> passthru ( $ size ) ; } $ buff = new Str ( "" ) ; $ size = intval ( $ size ) ; $ pack = 4096 ; Signal :: getInstance ( ) -> emit ( "filetransferDownloadStarted" , $ ftkey , count ( $ buff ) , $ size ) ; for ( $ seek = 0 ; $ seek < $ size ; ) { $ rest = $ size - $ seek ; $ pack = $ rest < $ pack ? $ rest : $ pack ; $ data = $ this -> getTransport ( ) -> read ( $ rest < $ pack ? $ rest : $ pack ) ; $ seek = $ seek + $ pack ; $ buff -> append ( $ data ) ; Signal :: getInstance ( ) -> emit ( "filetransferDownloadProgress" , $ ftkey , count ( $ buff ) , $ size ) ; } $ this -> getProfiler ( ) -> stop ( ) ; Signal :: getInstance ( ) -> emit ( "filetransferDownloadFinished" , $ ftkey , count ( $ buff ) , $ size ) ; if ( strlen ( $ buff ) != $ size ) { throw new Exception ( "incomplete file download (" . count ( $ buff ) . " of " . $ size . " bytes)" ) ; } return $ buff ; }
Returns the content of a downloaded file as a Str object.

@param  string  $ftkey
@param  integer $size
@param  boolean $passthru
@throws Exception
@return Str
Returns the content of a downloaded file as a Str object .