Adding filetransfer to PhoneGap breaks assembly

I am trying to upload a video to a server in PhoneGap. The code works in terms of opening the camera dialog box and recording video, but then JS in the index.html file requires the use of the FileTransfer plugin.

Adding this plugin from the command line in the telephone line results in the following error ...

/platforms/ios/ManUtd/Plugins/org.apache.cordova.file-transfer/CDVFileTransfer.m:23:9: file CDVLocalFilesystem.h not found

The html file is the documented code from the PhoneGap website.

<!DOCTYPE html>
<html>
<head>    
<title>Capture Video</title>    
    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">

        // Called when capture operation is finished
        //
        function captureSuccess(mediaFiles) {
            var i, len;
            for (i = 0, len = mediaFiles.length; i < len; i += 1) {
                uploadFile(mediaFiles[i]);
            }
        }

    // Called if something bad happens.
    //
    function captureError(error) {
        var msg = 'An error occurred during capture: ' + error.code;
        navigator.notification.alert(msg, null, 'Uh oh!');
    }

    // A button will call this function
    //
    function captureVideo() {
        // Launch device video recording application,
        // allowing user to capture up to 2 video clips
        navigator.device.capture.captureVideo(captureSuccess, captureError, {limit: 2});
    }

    // Upload files to server
    function uploadFile(mediaFile) {
        var ft = new FileTransfer(),
        path = mediaFile.fullPath,
        name = mediaFile.name;

        ft.upload(path,
                  "http://my.domain.com/upload.php",
                  function(result) {
                  console.log('Upload success: ' + result.responseCode);
                  console.log(result.bytesSent + ' bytes sent');
                  },
                  function(error) {
                  console.log('Error uploading file ' + path + ': ' + error.code);
                  },
                  { fileName: name });   
    }

        </script>
</head>
<body>
    <button onclick="captureVideo();">Capture Video</button> <br>
</body>
</html>

I executed both of these commands, and both of them lead to code breaking

$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git

$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git

I am targeting iOS only at the moment.

+3
source share
1 answer

This is like the whole PhoneGap / Cordova thing.

Cordova PhoneGap, . , FileTransfer API , PhoneGap.

+1

All Articles