我怎么才能优化这个?
<cfftp connection = "myConnection"
username = "#username#"
password = "#password#"
server = "#server#"
action = "open"
timeout = "500"
stopOnError = "Yes">
<cfloop index="i" from="1" to="#ArrayLen(ImagesArray)#">
<cfset slocal = "temp\" & ImagesArray[i] >
<cfset sremoteFile = "Images\" & ImagesArray[i]>
<cftry>
<cfftp
connection = "myConnection"
action = "getFile"
name = "uploadFile"
transferMode = "binary"
failIfExists = "false"
localFile = "#slocal#"
remoteFile = "#sremoteFile#" />
<cfcatch>
<cfabort>
</cfcatch>
</cftry>
<cfset files = files & "|" & slocalFile>
<cfset fileliste = fileliste & arFiles[i] & "|">
</cfloop>
<cfftp connection = "myConnection"
action = "close"
stopOnError = "Yes">发布于 2013-12-08 03:14:29
根据我的经验,FTP可以消耗大量的网络数据包和CPU时间,仅仅是协商一个文件的开始和完成。如果有在目的地解压缩存档的选项,我建议将图像压缩到一个文件中进行传输。
为了使发出CF请求的最终用户获得更高的性能,您可以通过cf线程在异步线程中执行FTP传输。启动压缩和发送文件的线程,并让用户知道数据正在进行中。
希望这会有所帮助,或者至少能激发出一些新的想法。
https://codereview.stackexchange.com/questions/23539
复制相似问题