FileTransfer is not defined

7 posts, 0 answers
  1. Rich
    Rich avatar
    22 posts
    Member since:
    Feb 2012

    Posted 06 Oct 2013 Link to this post

    I have a script that works under IOS but not under Android. Using Weinre this is what I got:

    processMessage failed: Message: S01 Capture1165431115 [{"lastModifiedDate":1381080555000,"fullPath":"file:\/\/\/mnt\/sdcard\/DCIM\/Camera\/VID_20131006_132911.mp4","type":"video\/mp4","size":1538739,"name":"VID_20131006_132911.mp4"}]
    processMessage failed: Error: ReferenceError: FileTransfer is not defined

    I checked to make sure filetransfer is enabled in the config.xml 

    It works great on my iphone but Just not on Android 4.  Any ideas or should I just not use the filetransfer plugin?
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 07 Oct 2013 Link to this post

    Hi Rich,

    The plugins listed in the Android config.xml are no longer taken into account since Cordova 3.0, we've just forgotten to remove them. In the current version of Icenium, you cannot remove any of the core Cordova plugins, your app uses all by default including the File API.

    Are you using FileTransfer to download or upload a file? What does your script do exactly and is it supported by Cordova and the Android WebView? You can review our file transfer sample that shows how it is used to download a file. You can refer to the Cordova File API for example how to upload a file.

    Regards,
    Steve
    Telerik
    You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  3. Rich
    Rich avatar
    22 posts
    Member since:
    Feb 2012

    Posted 07 Oct 2013 Link to this post

    I am using upload. Basically, after I capture an image or video or audio it is supposed to upload the result. The capturesuccess is called with the path and it works great on IOS.  On Android though it fails on line 6.

    Here is the code: 

    01._captureSuccess:function(capturedFiles) {
    02.    var i;
    03.    for (i=0;i < capturedFiles.length;i+=1) {
    04.        var mediaFile = capturedFiles[i];
    05.        console.log('Captured Successfully trying to upload now...');
    06.        var ft = new FileTransfer(),
    07.        path = mediaFile.fullPath,
    08.        name = mediaFile.name;
    09. 
    10.        $('#media').html(path + ' :: ' + name);
    11.         
    12.        ft.upload(path,
    13.                  "http://www.xxxxxx.com/test/upload.php",
    14.                  function(result) {
    15.                    console.log('Upload success: ' + result.responseCode);
    16.                    console.log(result.bytesSent + ' bytes sent');
    17.                     $("#file-list").data("kendoMobileListView").dataSource.read();
    18.                  },
    19.                  function(error) {
    20.                    alert('Error uploading file ' + path + ': ' + error.code);
    21.                  },
    22.                  { fileName: name });
    23.         
    24.    }
    25.}
  4. Rich
    Rich avatar
    22 posts
    Member since:
    Feb 2012

    Posted 08 Oct 2013 Link to this post

    It appears that the Device Ready is not firing on Android so that Cordova isn't working.

    I changed my device ready trying to get it to run, but nothing I do gets it to fire under Android.
    document.addEventListener("deviceready", function(){
        console.log('onDeviceReady');
        captureApp = new captureApp();
        captureApp.run();
        ft = new FileTransfer();
    },true);
  5. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 09 Oct 2013 Link to this post

    Hello Rich,

    There are numerous threads elaborating on possible culprits that could cause the deviceready event not to fire. If you are unable to identify the problem on your end, please let us know the name of your project and we would take a look at it.

    Regards,
    Steve
    Telerik
    You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  6. Rich
    Rich avatar
    22 posts
    Member since:
    Feb 2012

    Posted 09 Oct 2013 Link to this post

    I figured it out last night. End result was that there was no problem with the code. When I created the original file it was a sample with an older version of Cordova, I switched it to V3 but apparently that didn't fully work right. I archived it. Created a blank Cordova V3 project and imported my files in and ouila it worked beautifully.
  7. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 09 Oct 2013 Link to this post

    Hello Rich,

    Can you still let us know the name of your app that does not work, so we can investigate what goes wrong when switching Cordova version?

    Regards,
    Steve
    Telerik
    You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
Back to Top