public function writeFile($local, $remote, callable $progress = NULL)
{
$this->protect(function () use($local, $remote, $progress) {
$size = max(filesize($local), 1);
$len = 0;
$i = fopen($local, 'rb');
$o = fopen("ssh2.sftp://{$this->sftp}{$remote}", 'wb');
while (!feof($i)) {
$s = fread($i, 10000);
fwrite($o, $s, strlen($s));
$len += strlen($s);
if ($progress) {
$progress($len * 100 / $size);
}
}
});
}