コード例 #1
0
ファイル: FtpFile.class.php プロジェクト: xp-framework/ftp
 /**
  * Upload to this file from an input stream
  *
  * @param   io.streams.InputStream in
  * @param   int mode default FtpTransfer::ASCII
  * @param   peer.ftp.FtpTransferListener listener default NULL
  * @return  peer.ftp.FtpFile this file
  * @throws  peer.SocketException in case of an I/O error
  */
 public function uploadFrom(InputStream $in, $mode = FtpTransfer::ASCII, FtpTransferListener $listener = null)
 {
     $transfer = (new FtpUpload($this, $in))->withListener($listener)->start($mode);
     while (!$transfer->complete()) {
         $transfer->perform();
     }
     if ($transfer->aborted()) {
         throw new \peer\SocketException(sprintf('Transfer from %s to %s (mode %s) was aborted', $in->toString(), $this->name, $mode));
     }
     $this->refresh('upload');
     return $this;
 }