How to upload saved video to a remote server, captured using cordovaCapture?

眉间皱痕 提交于 2019-12-04 11:17:51

It is pretty simple. This will work only in ionic FW

first you must be installed file transfer plugin. if not use this command:

cordova plugin add org.apache.cordova.file-transfer

assume http://www.samplewebsite.com/upload. is your server hyperlink.

example.controller("ExampleController", function($scope, $cordovaFileTransfer) {

    $scope.upload = function() {
        var options = {
            fileKey: "avatar",
            fileName: "filename.mp4",
            chunkedMode: false,
            mimeType: "video/mp4"
        };
        $cordovaFileTransfer.upload("http://www.samplewebsite.com/upload", "file:/storage/....mp4", options).then(function(result) {
            console.log("SUCCESS: " + JSON.stringify(result.response));
        }, function(err) {
            console.log("ERROR: " + JSON.stringify(err));
        }, function (progress) {
            // constant progress updates
        });
    }

});

after all you need to call this function like this

<button class="button" ng-click="upload()">video upload</button>

Its working. I have done many times.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!