简体   繁体   English

phpseclib sftp put耗尽了1 GB +文件的内存

[英]Phpseclib sftp put runs out of memory with 1 GB+ files

I am trying to transfer large zip files using phpseclib's sftp put method. 我正在尝试使用phpseclib的sftp put方法传输大型zip文件。 Files under 1 GB or so transfer without any issue. 小于1 GB的文件可以顺利传输。 However, larger files are failing soon after reaching the 1 GB mark during transfer. 但是,较大的文件在传输过程中达到1 GB标记后很快就会失败。

I get this PHP error: 我收到此PHP错误:

"PHP Fatal error:  Out of memory (allocated 89653248) 
(tried to allocate 3717163274 bytes) in 
../lib/phpseclib/Net/SSH2.php on line 1553".   

Code: 码:

require_once('phpseclib/Net/SFTP.php');
require_once('phpseclib/Crypt/RSA.php');

$sftp = new Net_SFTP($host);
$key = new Crypt_RSA();
$key->loadKey(file_get_contents($privatekey));
$sftp->login($username, $key);

$sftp->put($remotefile, $localfile, NET_SFTP_LOCAL_FILE);

The memory_limit setting in my php.ini is set to -1. 我的php.ini中的memory_limit设置设置为-1。 Are there any other PHP settings that could be causing this limitation? 还有其他可能导致此限制的PHP设置吗? Or any settings in the phpseclib library that could help? 或phpseclib库中的任何设置可能有帮助?

You're running a super old version of phpseclib. 您正在运行phpseclib的超旧版本。 The 1.21 / 1.46 versions that you're referring to are populated through the CVS keyword $Id: $ and phpseclib hasn't used CVS in years. 您所指的1.21 / 1.46版本是通过CVS关键字$ Id:$填充的,并且phpseclib多年来没有使用CVS。

The last release version (as opposed to individual file commit version) of phpseclib that used those was 0.2.1 and the last commit for that version was in April 2010: 使用phpseclib的最新发行版(相对于单个文件提交版本)为0.2.1,该版本的最后提交于2010年4月:

https://github.com/phpseclib/phpseclib/blob/0.2.1/phpseclib/Net/SFTP.php#L51 https://github.com/phpseclib/phpseclib/blob/0.2.1/phpseclib/Net/SFTP.php#L51

Contrast that with the 0.2.2 release which doesn't have the CVS keyword $Id: $ stuff: 将其与0.2.2版本中没有CVS keyword $Id: $东西进行对比:

https://github.com/phpseclib/phpseclib/blob/0.2.2/phpseclib/Net/SFTP.php#L48 https://github.com/phpseclib/phpseclib/blob/0.2.2/phpseclib/Net/SFTP.php#L48

phpseclib is currently at 0.3.7. phpseclib当前为0.3.7。 There have been 6 version releases since 0.2.1 (0.2.2, 0.3.0, 0.3.1, 0.3.5, 0.3.6 and 0.3.7) so try upgrading . 自0.2.1(0.2.2、0.3.0、0.3.1、0.3.5、0.3.6和0.3.7)以来,已经有6个版本发行,因此请尝试升级

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM