Skip to content

Commit

Permalink
SFTP: add stream to get method
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian authored and terrafrost committed Nov 27, 2020
1 parent 40b67bf commit 9547587
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions phpseclib/Net/SFTP.php
Expand Up @@ -2278,7 +2278,7 @@ function get($remote_file, $local_file = false, $offset = 0, $length = -1, $prog
$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;
Expand All @@ -2288,7 +2288,7 @@ function get($remote_file, $local_file = false, $offset = 0, $length = -1, $prog
}
}

$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;
Expand Down Expand Up @@ -2335,6 +2335,8 @@ function get($remote_file, $local_file = false, $offset = 0, $length = -1, $prog
$offset+= strlen($temp);
if ($local_file === false) {
$content.= $temp;
} elseif (is_callable($local_file)) {
$local_file($temp);
} else {
fputs($fp, $temp);
}
Expand Down

1 comment on commit 9547587

@terrafrost
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1546

Please sign in to comment.