/** * {@inheritdoc} */ public function download($local, $remote) { $this->checkConnection(); if (!$this->sftp->get($remote, $local)) { throw new \RuntimeException(implode($this->sftp->getSFTPErrors(), "\n")); } }
public function putContent($content, $dest) { if (false === $this->isConnected()) { $this->connectAndLogin(); } $this->dispatcher->dispatch(TransporterEvents::TRANSPORTER_PUT_CONTENT, new TransporterEvent($this, array('dest' => $dest, 'content' => $content))); $success = $this->sftp->put($dest, $content, PhpseclibSFTP::SOURCE_STRING); if (!$success) { // maybe the parent directory doesnt exist; try to create it and try again $pwd = dirname($dest); if (false === $this->exists($pwd)) { $this->mkdir($pwd); // retry try to put $success = $this->sftp->put($dest, $content, PhpseclibSFTP::SOURCE_STRING); if (!$success) { throw new \RuntimeException('Something went wrong: ' . "\n" . implode("\n", $this->sftp->getSFTPErrors())); } } } }