I’m trying to upload to firebase using $ cordovaCamera, so android is all right as shown in the image below:
However for IOS probably the directory is different and at the time of replacing some error
function getPicture(type) {
$cordovaCamera.getPicture({
destinationType: Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
sourceType: type,
allowEdit: true,
targetWidth: 720,
targetHeight: 500
}).then(function (res) {
window.resolveLocalFileSystemURL(res, function (fileEntry) {
$timeout(function () {
var nativeURL = fileEntry.nativeURL;
var url = nativeURL.replace(cordova.file.applicationStorageDirectory, '');
$scope.picture = url;
console.log(url);
});
});
}).catch(function (error) {
console.log(error);
});
}
The code where I make the replace file
function getFileBlob(url, cb) {
console.log(url);
if (url == undefined) {
} else {
var path = url.substring(0, url.lastIndexOf('/') + 1);
var filename = url.substring(url.lastIndexOf('/') + 1, url.length);
}
console.log('path', path);
console.log('file', filename);
$cordovaFile.readAsArrayBuffer(path, filename)
.then(function (success) {
var blob = new Blob([success], { type: 'image/jpeg' });
cb(blob);
}, function (error) {
console.error(error);
cb(null);
});
}