Dave
Dave

Reputation: 596

Flex File I/O Error #2038 - file.upload fails on Mobile IOS

I need to upload an xml file to the server with a IOS application developed in Flex. I am getting a Flex File I/O Error #2038. It is a very generic i/o error and doesn't provide any further details that would help me track down the root problem. Everything goes well on Windows when debugging the App it only happens when I debug the App on the apple Air tablet.

I ran into this post https://www.catalysts.cc/en/wissenswertes/flex-file-io-error-2038-on-mac-clients/ which looks like something similar but to be honest I wasn't able to use this information. It seems that my tablet may be corrupting the URL. I haven't made any traffic monitoring but I can swear the call is not even made.

Here is the code:

 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);

The request parameters are:

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"

And I get the error:

 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}}]

I really need help here... Thanks

Should I try something like this:

 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);

Upvotes: 0

Views: 1063

Answers (2)

Dave
Dave

Reputation: 596

The solution for my problem was encoding the URL I changed the code to:

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;
    }

Upvotes: 0

simion314
simion314

Reputation: 1394

Try using the UrlVariables class Documentation

Upvotes: 1

Related Questions