How to add video from device to my upload function?

My plan is to create an app that make use of and it´s upload-cordova.js. The app has a Choose Video button with showOption() that opens a ionicActionSheet that let you choose to either captureVideo or togetPicture(Camera.MediaType.VIDEO) from the device library. When this is done, the video is added to a player <cordova-video src="data.videoPath"></cordova-video> that that are able to play the chosen video. When the video this way is added to the player, a button with the ng-click="uploadVideo()" function shows up($ = true;). Pressing this button will cause the current video in the player to be uploaded to my Vimeo account. For sure the upload attempt starts and the progress-bar shows a progress. Also instantly my vimeo account display an Untitled video template and when I click its title, the video page display a ordinary Uploading animation and the text: Your video is uploading. Unfortunately, the progress newer finishes. The var files in uploadVideo obviously does not contain or find the file(video) to upload. The $; seems to be just a string. Can someone tell me how to identify the video(object) used by videoPath and how to add it to the files array (var files = [];) ? I would be so glad for any help on this. See my code below:

$ = false;

$ = {
videoPath: “”

$scope.caption = “Choose Video”;

// captureVideo function
$scope.captureVideo = $scope.captureVideo = function(){
var options = {
quality: 50,
limit: 3,
duration: 15 };

  // Success! Video data is here
  $ = "file:/" + videoData[0].fullPath;
  $ = true;
  $scope.caption = "Choose new Video";
}, function(err){
  // An error occurred. Show a message to the user


// find video on device function
$scope.getPicture = function(sourceType){
var options = {
quality: 50,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,

// Success! Video data is here
$ = imageData;
$ = true;
$scope.caption = “Choose another Video”;
}, function(err) {
// An error occurred. Show a message to the user

$scope.showOptions = function(){
var hideSheet = ${
buttons: [{
text: ‘Choose a recording’
}, {
text: ‘Make a recording’
destructiveText: ‘’,
titleText: ‘What do you want?’,
cancelText: ‘Cancel’,
cancel: function(){
buttonClicked: function (index){
// Choose existing recording
if(index === 0){
// Create new recording
else if(index === 1){
// Cancel operation
else {

           return true;



// This is the function that I want to start the upload to Vimeo with
$scope.uploadVideo = function(){

 var files = [];
// Here lies my problem. videoPath is a string, 
//not the file(video) that videoPath points to.

//What is the name of the file/video object in my case??

 files[0] = $; 

 var accessToken = " "; // accesstoken to Vimeo upload API are hidden in this text

 // Rest the progress bar

 var uploader = new MediaUploader({
   file: files[0],
   token: accessToken,

   onError: function(data) {

     console.log('Error ', data);

     var errorResponse = JSON.parse(data);
     message = errorResponse.error;

   onProgress: function(data) {
     console.log('in progress...');

     $scope.updateProgress(data.loaded /;

   onComplete: function(videoId) {
     console.log('Complete ',videoId);

     var url = ""+videoId;
     var a = document.createElement('a');

     var element = document.createElement("div");
     element.setAttribute('class', "alert alert-success");




did u find out how to do this?
im trying to do exact same thing and cant understand how to convert the uri im getting to 'file’
that mediauploader is excepting.

will be thankful for any help

Hi. Great to find someone that is working on a similar case. Maybe we could help each other along the way. I have been trying to get this Vimeo Upload to work for a long time, but unfortunately there have not been a long line of developer that have come up with an answer so far. We still have to cross our fingers.

Hi all i am also getting the same problem as i am trying to access the video path using $cordovaCamera plugin, here is my code:-

$scope.getVideoPath = function(){
var options = {
quality: 50,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
$cordovaCamera.getPicture(options).then(function(videoURI) {
}, function(err) {

I am getting both the log blank

did u get solution?..

Did anyone get Solution to this??

Sorry @gowda , I have not got any help with this. You can find my project at:

so if you would like to try to solve the problem, your welcome. As far as this app goes, a valid video file is not uploaded. The app need to preserve FileReader with a FileURI, not just a FilePath.

You need to change the accessToken to your own. Of cause, if you solve this, I would like to know.

I’d surely get back to you on this if I get any solution

$cordovaFile.readAsArrayBuffer(“file:/storage/sdcard0/DCIM/Camera/”,“filename”).then(function (success) {}

try ths u may get it…

$scope.captureVideo = function () {

              var options = {
                          quality: 50,
                          destinationType: Camera.DestinationType.FILE_URL,
                          sourceType: Camera.PictureSourceType.CAMERA

          $cordovaCapture.captureVideo(options).then(function(videoData) {
          $scope.clip = videoData[0].fullPath;

              var first=$scope.clip.substr(0,$scope.clip.lastIndexOf('/')+1);

                  .then(function (success) {

                var bucket = new AWS.S3({params: { Bucket: 'jbf-dev-bucket' }});

                  var params = {

                    Key: videoData[0].name, 
                    ContentEncoding: 'base64', 
                    ContentType: 'video/mp4', 
                    Body: success

                  bucket.upload(params).on('httpUploadProgress', function(evt) {
                    $scope.uploading = true;
                    $scope.progress = parseInt((evt.loaded * 100) /'%';
                    console.log("Uploaded :: " + $scope.progress );         
                  }).send(function(err, data) {
                    $scope.uploading = false;


                  }, function (error) {



            accessKeyId : 'YOUR ACCESSKEYID',
            secretAccessKey : ' YOUR SECREATACCESSKEY'

im uploading captured video to amazon s3 bucket…its working…make changes and do it…

I have tried the code but I get and ENCODING_ERR from the readAsDataURL method. Does anybody else has the same problem?