Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Aya_S_
Beginner
117 Views

Cordova File-transfer plugin not responding with XDK platform

I am trying to upload a video to back end service using File-transfer plugin and XDK development Platform

 - Testing on Android Lollipop system and XDK emulator.
 - My system is windows 7
 - XDK version is: 2893

My Code is

    function uploadVideo(){
            alert("button Clicked");
    
        var url = '';
        var filePath = Uservideo.videoPath;
        var fileTransfer = new FileTransfer();
        var uri = encodeURI(url);
        
         var params = {filename: Uservideo.videoPath,
                     category_id:"1",
                     about:"whatever",
                     access_token:userHandler.login_token};
        
        var options = new FileUploadOptions();
        options.httpMethod="POST";
        options.fileKey = "file";
        options.fileName = Uservideo.videoPath.substr(Uservideo.videoPath.lastIndexOf('/') + 1);
        options.mimeType = "video/mp4";
        options.params = params;
        
            alert(JSON.stringify(options));
            alert(filePath);
            console.log("filePath: "+filePath);
        
        fileTransfer.upload(filePath,
            url,
            function(entry) {
                console.log("upload complete: " + entry.fullPath);
            alert("success"+entry);
            },
            function(error) {
                console.log("upload error source " + error.source);
                console.log("upload error target " + error.target);
                console.log("upload error code" + error.code);
            },options);
    }



Help Am STUCK

The issue is I am trying to debug and find how the function reacts in my application but i never got an error or a success response from the back-end or the debugger, the function is not even seen i guess

A friend used my code and run it using phonegap terminal and claimed that it worked fine with him."am not sure"

I just can't determine where's the issue
is it XDK?
is it the plugin itself?
is it my way of implementing the code?
is it the back-end service?

Help Am STUCK

Tags (2)
0 Kudos
8 Replies
Amrita_C_Intel
Employee
117 Views

Hello,

1) Please upgrade the Intel XDK to 3088.

2) Try removing the plugin and building after that.

3)Limitation of emulator: You should think of the Emulate tab as a Cordova API simulator, not as a device emulator. It provides you with a convenient viewport to help you visualize the approximate layout of your app on various devices and itsimulates the core Cordova APIs to make it easier to debug apps that use those APIs. It does not simulate real devices nor does it simulate third-party Cordova plugin APIs. Getting your app to work in the Emulate tab is not a guarantee that it will work on a real device. Conversely, if things work on a real device but do not work in the Emulate tab, that is not an indication that your app is "broken." The only way to know with certainty that your app works as intended is to build it and install it on real devices.

4) Lastly you can send the .Zip file of the project through PM.

Swati_S_Intel1
Employee
117 Views

@Aya, have you selected appropriate whitelisting rules? Please see this article for set the whitelist rules : https://software.intel.com/en-us/articles/cordova-whitelisting-with-intel-xdk-for-ajax-and-launching-external-apps.

Aya_S_
Beginner
117 Views

@amrita
I did updated my project to the latest version and am testing on a real android device with a lollipop OS

 

@Swati the whitlist access setting is set to * which as  allows all kind of websites as mentioned in docs

Is there's any other solution to upload and download videos instead of File-transfer plugin?

Swati_S_Intel1
Employee
117 Views

What error are you getting? Is your server side script working? 

Can you get the value of error.code and error.http_status? If you are not getting anything from the server then you might have to check your server side script.

Aya_S_
Beginner
117 Views

When using normal Jquery post methodm I am getting a success status 200 and Ok, but the server keeps replying that i didn't send a file
we tested the service using Postman chrome plugin and the file got uploaded okay, logged the video file path and it's percise too but still the server detected no file to receive

when using file transfer plugin as mentioned in the post, it just acts like a ghost not responding with negative or positive, I need a solution as soon as possible i have to deliver the app in a cpl of days

 

Swati_S_Intel1
Employee
117 Views

Please check your file path. For each device type the webroot is different. Use this function to get the root path and reference your file relative to this path.

function getWebRoot() {
    "use strict" ;
    var path = window.location.href ;
    path = path.substring( 0, path.lastIndexOf('/') ) ;
    return path ;
}

Also, make sure you have included the plugin through plugin manager and are using the correct version of the plugin.

Aya_S_
Beginner
117 Views

It worked, the solution was;

1- changing the plugin  version from 1.5 to 1.4

2- add whitelist permissions mannually to the intelxdk.addition.config.xml

<allow-navigation href="http://*/*" />
<access origin="*" />

 

Not pretty sure what was happening exactly, was it the plugin version or the missing permissions or both, if someone can explain

Swati_S_Intel1
Employee
117 Views

@Aya, if those two are the only things you changed then the plugin version might be the issue. Setting whitelisting through additions file should not make a difference. I recommend that you set your whitelisting settings through the UI only. 

Reply