I want to save an image from an ios application to the image gallery, so the user can share it.
My app is using ionic framework & ngCordova. I am trying to save the image like this:
image = cordova.file.applicationDirectory + "www/img/deck/" + card.image;
file_path = cordova.file.documentsDirectory + "wisdom.png";
$cordovaFile.createFile(file_path, true).then(function(result) {
alert(JSON.stringify(result));
}, function(err) {
alert('create error: ' + JSON.stringify(err));
});
$cordovaFile.writeFile(file_path, image).then(function(result) {
alert(JSON.stringify(result));
}, function(error) {
alert(JSON.stringify(err));
});
This gives an error code 5, ENCODING_ERR - when creating the file. The write file does not give a success or fail error. There is no image in the gallery. What should the path be to save the file? How should i send the image to the write method? Why am i getting an encoding error?