From 9547587cb79aa98082cd778fb52c5b6fe2834df6 Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 26 Nov 2020 10:45:53 +0000 Subject: [PATCH] SFTP: add stream to get method --- phpseclib/Net/SFTP.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index a94215b8..dbd23137 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -2278,7 +2278,7 @@ class Net_SFTP extends Net_SSH2 $res_offset = $stat['size']; } else { $res_offset = 0; - if ($local_file !== false) { + if ($local_file !== false && !is_callable($local_file) ) { $fp = fopen($local_file, 'wb'); if (!$fp) { return false; @@ -2288,7 +2288,7 @@ class Net_SFTP extends Net_SSH2 } } - $fclose_check = $local_file !== false && !is_resource($local_file); + $fclose_check = $local_file !== false && !is_callable($local_file) && !is_resource($local_file); $start = $offset; $read = 0; @@ -2335,6 +2335,8 @@ class Net_SFTP extends Net_SSH2 $offset+= strlen($temp); if ($local_file === false) { $content.= $temp; + } elseif (is_callable($local_file)) { + $local_file($temp); } else { fputs($fp, $temp); }