/** * 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 = create(new FtpUpload($this, $in))->withListener($listener)->start($mode); while (!$transfer->complete()) { $transfer->perform(); } if ($transfer->aborted()) { throw new SocketException(sprintf('Transfer from %s to %s (mode %s) was aborted', $in->toString(), $this->name, $mode)); } $this->refresh('upload'); return $this; }