I’m working under file uploading, for that purpose I need to read file as binaryString.
The process scheme is:
User choose image from gallery -> Image path is used to get file as binary string.
$cordovaCamera.getPicture(cordovaHelper.getGalleryOptions()).then(function(imageUrl) {
//imageUrl like file://someDir/someDir/someDir/image.jpg
var lastIndexOfSlash = imageUrl.lastIndexOf('/');
//filePath is file://someDir/someDir/someDir
var filePath = imageUrl.substr(0, lastIndexOfSlash); //p
//fileName is image.jpg
var fileName = imageUrl.substr(lastIndexOfSlash + 1, imageUrl.length);
$cordovaFile.readAsBinaryString(filePath, fileName).then(function(binaryString) {
$scope.event.binaryString = binaryString;
}, function(error) {});
});
I have tried to use corodova.file (cordova.file.tempDirectory), but it’s not defined
But the plugin is installed, if I exec ‘cordova plugin’ to get list of installed plugins I can find in that list:
cordova-plugin-file 2.1.0 “File”