为什么CF FTP传输速度比标准FTP慢几倍?
|
我有一个ColdFusion应用程序,用于在开发服务器和生产服务器之间传输文件。实际发送文件的代码如下:
ftp = new Ftp();
ftp.setUsername(username);
ftp.setPassword(password);
ftp.setServer(server);
ftp.setTimeout(1800);
ftp.setConnection(\'dev\');
ftp.open();
ftp.putFile(transferMode=\"binary\",localFile=localpath,remoteFile=remotepath);
ftp.close(connection=\'dev\');
使用上述代码发送文件时,我的输出速度接近100KB / s(通过接收服务器上的FileZilla监视)。如果使用Windows命令行FTP工具发送完全相同的文件,则速度将超过1000KB / s。
我创建了一个全新的文件,只带了上面的代码,并且对传输速度没有任何影响,因此我知道它与原始应用程序中的周围代码无关。
那么,是什么原因导致这些低速行驶呢?
编辑:所有测试都已完成,将文件从生产服务器传输到开发服务器。我也尝试使用<cfftp>
标记而不是cfscript,结果也相同。
编辑#2:我最终使用cfexecute
,代码如下:
从我的FTP脚本中:
public function sendFiles(required string localpath, required string remotepath) {
this.writeFtpInstructions(localpath);
exe = \"C:\\Windows\\system32\\ftp.exe\";
params = \"-s:\" & request.localapproot & \"/\" & \"upload.txt\";
outputfile = request.localapproot & \'/ftp.log\';
timeout = 120;
Request.cliExec(exe,params,outputfile,timeout);
}
public function writeFtpInstructions(required string localpath) {
instructions = request.localapproot & \"/\" & \"upload.txt\";
crlf = chr(13) & chr(10);
data = \"\";
data &= \"open \" & this.server & crlf;
data &= this.username & crlf;
data &= this.password & crlf;
data &= \"cd \" & request.remoteapproot & crlf;
data &= \"put \" & localpath & crlf;
data &= \"quit\";
FileWrite(instructions, data);
}
cliExec()
函数(由于在cfscript中没有cfexecute
等效项,因此必须创建包装器):
<cffunction name=\"cliExec\">
<cfargument name=\"name\">
<cfargument name=\"arguments\">
<cfargument name=\"outputfile\">
<cfargument name=\"timeout\">
<cfexecute
name=\"#name#\"
arguments=\"#arguments#\"
outputFile=\"#outputfile#\"
timeout=\"#timeout#\" />
</cffunction>
没有找到相关结果
已邀请:
2 个回复
浮凰量
藐刚
结果:
实现的传输速度与使用FileZilla FTP Client和手动下载获得的速度相当。我发现此方法对于cfftp的不足是一种可行的解决方案。