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:
- “file://” + imageURI
- 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.