Using http://ngcordova.com/ I'm having trouble trying to save the photo into the gallery on Android.
Initially the file wasn't passing the image data back after taking the picture when using the following options ;
var options = {
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.CAMERA,
encodingType: Camera.EncodingType.JPEG,
correctOrientation: true,
saveToPhotoAlbum: true
};
I found that to fix this I had to downgrade the camera plugin from 0.3.6 to 0.3.5 thanks to forum.
The routine that saves is as follows ;
$cordovaCamera.getPicture(options).then(function (imagePath) {
var currentName = imagePath.replace(/^.*[\\\/]/, '');
var d = new Date(),
n = d.getTime(),
newFileName = n + ".jpg";
//Move the file to permanent storage
$cordovaFile.moveFile(cordova.file.externalRootDirectory, currentName, cordova.file.externalRootDirectory + "DCIM/Camera", newFileName).then(function(success){
//sucess
}, function(error){
//an error occured
//Booooooo
});
I don't want to hard code paths but was just testing to see if I could get the photo in the correct directory. I had tried the directories from this post.
I found on my Nexus 5 though the cordova.file.tempDirectory was always null.
Is it a bug with the camera plugin for saving to Gallery or is it not just implemented correctly yet for Android.
Cheers for any help.