Uploading a Video [solved]

I’m trying to upload a video from the camera roll. This is my code. iOS returns null for data for a video, but returns the right filepath for an image. Can’t tell where the bug is occurring - but it does not seem intended! Any help would be awesome.

$scope.chooseVideos = function() {
  var options = {
    destinationType: Camera.DestinationType.FILE_URI,
    sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,
    mediaType: Camera.MediaType.ALLMEDIA
  };
 
  $cordovaCamera.getPicture(options).then(function(data) {
    console.log("data from chooseVideos", data);
    // $scope.media.push(data.localURL);
  }, function(error) {
    // error getting photos
  });
}

you are using the wrong plugin http://ngcordova.com/docs/plugins/capture/ :wink:

actually that plugin works fine now. I got it working. The issue is inconsistent local filepaths cross images and videos. images inclue file:/// - videos do not.

lols nice to know. ^^

Can you tell me how exactly did you fix it as I am having the same issue. So how do we get the video path

hey there - you should add file:/// to retrieve the file.

the other bug which you should be aware of is that iOS will compress all videos and there is no way around this. Android will send you the uncompressed files.

Do you have skype so u mean i should just when i allert concatenate file:/// along with it

Still not able to understand what you mean you should add file:/// to retrieve the file. Please can explain with code

ur problem is solved or not…can send me the demo

@gowda @bengtler @jeffchuber
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, mediaType:Camera.MediaType.VIDEO }; $cordovaCamera.getPicture(options).then(function(videoURI) { console.log("videoURI",JSON.stringify(videoURI)); console.log("videoURI",videoURI.toURI()); }, function(err) { console.log("err",JSON.stringify(err)); }); }

I am getting both the log blank :disappointed:

I just used it many ways and tried your way also but m getting blank data on selection of video. It means video selection library apeared but on select of video it is giving blank data… so how can i get data or file path

How to get file path?

Simple way: use a standard file button. Put this in your template:

<input type="file" value = "upload" accept="video/*" id="videoButton" />

Then grab the information in your ts file like so:

let videoButton = (<HTMLInputElement>document.getElementById('videoButton'));
let videoFile = videoButton.files[0];

Then write what’s at the videoFile path to whatever database you’re using.

Once you have that working, you can make things fancier.