Get size of selected video file with cordova camera plugin. "getMetadat" does not work with the file url


#1

I am trying to get the size of a file selected with the cordova camera plugin. I have got this code to read the video library of the device.

var options = { 
    destinationType: Camera.DestinationType.FILE_URI,
    sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
    mediaType:Camera.MediaType.VIDEO
};

navigator.camera.getPicture(
    function(imageURI) {
        $scope.form_data.videofile  =   "file://" + imageURI;

        var entry = new FileEntry('video1', $scope.form_data.videofile);
        entry.getMetadata(
            function (metadata) {
                console.log("Last Modified: " + metadata.modificationTime);
            }, 
            function (error) {
                alert(error.code); // GOT ERROR NUMBER 5
            });
    }, 
    function(message) {
        alert('Failed because: ' + message);
    }, options);    

I tried with this two path:

  1. “file://” + imageURI
  2. imageURI

In both cases I obtain error code number 5, wich is FileError.ENCODING_ERR according this documentation. https://cordova.apache.org/docs/en/1.5.0/phonegap/file/fileerror/fileerror.html The error code means that the url is malformed, but I upload the video file with that url (“file//” + imageURI).

Any ideas of this? Thank you.


#2

Did you solve this one? I’m having the same issue.


#3

Also having this issue, were you able to solve this?


#4

Did you solve this? Also have the issue.


#5

How can get size and modificationTime when in function use file.getMetadata(…)?
size and time return 0 and null.

    this.file.listDir(this.path,'files').then((files:any) =>{
        files.map((val)=>{
              if(val.isFile){
	    let Fsize=0;
	    let modifydate= '';
 	    val.getMetadata(function (metadata){}).then(meta => {
	        Fsize= meta.size; // Get file size.
		modifydate = meta.modificationTime;
	    });  
	this.latestConvertion.unshift({
                name: val.name,
                path : val.nativeURL,
	        modifydate: modifydate,//can not get value
	        Fsize: Fsize //can not get value
            });
          }
        })
      }).catch(error=> console.log(JSON.stringify(error)));

Please help me. Thanks so much.