0

I have created and app in windows and android using the phonegap+jquery mobile. I have a file upload function which is working correctly on android build but in windows build it is showing an error code 3(FileTransferError.CONNECTION_ERR).

My code is as follows :

var options = new FileUploadOptions();
        options.fileKey = "file";
        options.fileName = 'xxxxxx.mp3';
        options.mimeType = 'audio/mpeg3';
        var fileFullPath = rootFolderPath+"xxxxxx.mp3";
        var params =  new Object();
        params.songId = 12;
        options.params = params;
        options.headers = {
               Connection: "close"
        }
        options.chunkedMode = false;
        var uploadUrl = "www.myapiurl.com";        
        var ft = new FileTransfer();
        ft.upload(fileFullPath, encodeURI(uploadUrl), winUpload, failUpload, options);

Please anyone help me to sort this out. Thank you all

Amesh
  • 177
  • 2
  • 12

1 Answers1

0

Looking at the source for the Windows implementation of the file-transfer plugin, it returns CONNECTION_ERR if it gets no response at all when trying to contact the server, so I suspect it might be a security problem; maybe a CORS issue? Do you have <access origin="*" /> in your config.xml file (this is the Cordova default)? Also, if you're using jQuery Mobile, are you calling $.mobile.allowCrossDomainPages in your startup code (the JQM default is "do not allow")?

Also on Windows Phone 8 (and this is specifically for 8 vs. 8.1) you need to grant both the "Internet (Client and Server)" and "Private Networks" capabilities in the package.windows80.appxmanifest file so that you can access the user's public and work/private internet connections, otherwise you'll get a connection error:

<Capabilities>
    <Capability Name="internetClientServer" />
    <Capability Name="privateNetworkClientServer" />
</Capabilities>

There's a complete writeup on these capabilities here:

https://msdn.microsoft.com/en-us/library/windows/apps/hh770532.aspx

Mike Dailor
  • 1,226
  • 8
  • 16