Flex文件I / O错误#2038 - 在Mobile IOS上file.upload失败

时间:2014-06-26 16:24:36

标签: actionscript-3 flex file-upload flex3 flex4.5

我需要使用Flex开发的IOS应用程序将xml文件上传到服务器。我得到了一个 Flex文件I / O错误#2038。这是一个非常通用的i / o错误,并没有提供任何可以帮助我找到根本问题的更多详细信息。在调试应用程序时,Windows上的一切进展顺利只有在Apple Air平板电脑上调试应用程序时才会发生。

我遇到了这篇文章https://www.catalysts.cc/en/wissenswertes/flex-file-io-error-2038-on-mac-clients/,看起来像是类似的东西,但老实说,我无法使用这些信息。我的平板电脑似乎可能正在破坏网址。我还没有进行任何交通监控,但我发誓甚至没有发出通话。

以下是代码:

 var f:File = new File('app-storage:/Output_WithAllInfo.xml');
 var request:URLRequest = new URLRequest();
 request.url = http://myHost/JsonServer/?country=DE&language=deu&operationtype=custom&select=[{\"item\":\"*\"}]&sessionid="+sessionId+"&custom=[{\"package\":\"eu.app\",\"name\":\"syncInUpload\",\"data\":{\"nxpkeyProcessId\":"+processId+",\"nxpkeyProcessDefinitionId\":null,\"xml\":null}}]";
 request.method = URLRequestMethod.POST;
 f.upload(request,"xml", false);

请求参数为:

authenticate:true
cacheResponse:true
 contentType:null
data:null
digest:null
followRedirects:true
idleTimeout:0
manageCookies:true
method:"POST"
requestHeaders:[] length:0
url:http://domain/JsonServer/?country=DE&language=deu&operationtype=custom&select=[{"item":"*"}]&sessionid=b9f33c5e-0445-49d3-ab5c-a335229596cf&custom=[{"package":"eu.app","name":"syncInUpload","data":{"nxpkeyProcessId":606,"nxpkeyProcessDefinitionId":null,"xml":null}}]
useCache:true
userAgent:"Mozilla/5.0 (iOS; U; de) AppleWebKit/533.19.4 (KHTML, like Gecko) AdobeAIR/3.7"

我收到错误:

 Error #2038: File I/O Error. URL: http://domain/JsonServer/?country=DE&language=deu&operationtype=custom&select=[{"item":"*"}]&sessionid=b9f33c5e-0445-49d3-ab5c-a335229596cf&custom=[{"package":"eu.app","name":"syncInUpload","data":{"nxpkeyProcessId":606,"nxpkeyProcessDefinitionId":null,"xml":null}}]

我真的需要帮助...... 感谢

我应该尝试这样的事情:

 var req:URLRequest=new URLRequest("url");
req.method=URLRequestMethod.POST;
var postData:URLVariables=new URLVariables();
postData.country= 'DE';
postData.language='deu';
postData.operationtype= 'custom';select='[{\"item\":\"*\"}]';
sessionid=e.session;
custom='[{\"package\":\‌​"eu.app\",\"name\":\"syncInUpload\",\"data\":\"nxpkeyProcessId\":606,\"nxpkeyProc‌essDefinitionId\":null,\"xml\":null}}];
req.data = postData;
var loader:URLLoader = new URLLoader();
loader.dataFormat=URLLoaderDataFormat.BINARY;
loader.addEventListener‌​(Event.COMPLETE,
loader_complete);
loader.load(req);

2 个答案:

答案 0 :(得分:1)

尝试使用UrlVariables类Documentation

答案 1 :(得分:0)

我的问题的解决方案是编码我将代码更改为:

的URL
var f:File = new File('app-storage:/Output_WithAllInfo.xml');
var request:URLRequest = new URLRequest();
var jsonParams:String = "/JsonServer/?country="+e.country+"&language="+e.lang+"&operationtype=custom&select=[{\"item\":\"*\"}]&sessionid="+e.sessionId+"&custom=[{\"package\":\"eu.app\",\"name\":\"syncInUpload\",\"data\":{\"nxpkeyProcessId\":"+e.processId+",\"nxpkeyProcessDefinitionId\":null,\"xml\":null}}]";
request.url = GlobalCGStaticVars.ipAddressJsonCalls+htmlencodeSpecial(jsonParams);
request.url = 'http://myHost'+htmlencodeSpecial(jsonParams);
request.method = URLRequestMethod.POST;
f.upload(request,"xml", false);


protected function htmlencodeSpecial(str:String):String
    {
        var result:String = '';
        for (var i:int=0 ; i< str.length; i++)
        {
            var unicode:String = '';

            if(str.charAt(i)=='{')
                unicode = '%7B';
            else if(str.charAt(i)=='[')
                unicode = '%5B';
            else if(str.charAt(i)==':')
                unicode = '%3A';
            else if(str.charAt(i)==']')
                unicode = '%5D';
            else if(str.charAt(i)=='}')
                unicode = '%7D';
            else if(str.charAt(i)=='"')
                unicode = '%22';
            else 
                unicode =  str.charAt(i);


            result += unicode;
        }
        return result;
    }