在我的问题之前有一点历史,我发布了一个关于使用HTML5的multipart/form-data将多个文件上传到coldfusion的问题.它工作得很漂亮. 你能否从CF10编译器中看到代码?
我们的客户端终于要求对我放在一起的RESTful函数进行一些单元测试,并且我已经完成了很多工作,但是我已经遇到了上面设计的massUpload函数的障碍.
对于长期问题,请记下与问题相关的问题.
这是有问题的代码:
单元测试代码:
//Outside class calling sendHTTPrequest
HashMap<String,String> map = new HashMap<String,String>();
HashMap<String,File> getFiles = getFirstFileList();
map.put("testMethod", "massUploadTest");
map.put("method", "massUpload");
map.put("valueString1", valueString1);
map.put("valueString2", valueString2);
map.put("valueNumeric3", valueNumeric3);
map.put("valueBoolean4", valueBoolean4);
map.put("valueString5", valueString5);
map.put("valueBoolean6", valueBoolean6);
map.put("valueString7", valueString7);
try {
sendHTTPrequest(map, getFiles);
} catch(RuntimeException e) {
throw new RuntimeException("Fatal error in massUpload\n"
+ e.getMessage());
}
//End Call class code
Run Code Online (Sandbox Code Playgroud)
Coldfusion功能:
<cffunction name="massUpload" access="remote" returntype="string">
<cfargument name="valueString1" type="string" required="false">
<cfargument name="valueString2" type="string" required="false">
<cfargument name="valueNumeric3" type="numeric" required="false" default=0>
<cfargument name="valueBoolean4" type="boolean" required="true" …Run Code Online (Sandbox Code Playgroud) 所以我刚接触coldfusion的编码,这是我的第二个月,所以请耐心等待.
我的雇主的客户希望顺利上传多个文件处理错误,这意味着即使出现错误,它也会继续通过所有上传.
所以使用CF11,我可以使用uploadAll,并启用continueOnError和Errors的可选值来轻松处理多个文件.
问题是,我的雇主的测试服务器仍然只是CF10,可能不会很快得到更新.因此,在我们的测试服务器上编译时,continueOnError和Error将失败,但在客户端服务器上则不会.
我希望能够做到这样的事情:
<cfif SERVER.ColdFusion.ProductVersion gte 11>
<optimal cffile uploadAll code>
<cfelse>
<suboptimal cffile uploadAll code>
</cfif>
Run Code Online (Sandbox Code Playgroud)
编译没有任何问题.但是测试服务器仍然存在代码问题.有什么办法可以在代码中完成吗?如果没有,有没有办法让我可以相当容易地做到这一点......是吗?