After upgrading to the latest cordova camera lib 0.3.4, I am able to get the real image uri after selecting an image from gallery, the returned file call pic.jpg, however if I select another one, it will return the same image with the same name pic.jpg, so I am stuck with the same image :(
the image path looks like file:///storage/emulated/0/android/data/app/cache/.pic.jpg
Any idea?
https://github.com/apache/cordova-plugin-camera/blob/master/src/android/CameraLauncher.java
$scope.getPhoto = function() {
// Retrieve image file location from specified source
navigator.camera.getPicture($scope.processImageUri, $scope.onFail, {
quality: 88,
correctOrientation: true,
encodingType: Camera.EncodingType.JPEG,
destinationType: navigator.camera.DestinationType.FILE_URI,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,
allowEdit: true
});
I also faced this issue on iOS platform (iOS 10.2). I didn't want to use accepted solution of moving to DATA_URI because I am using same code between iOS and Android and wanted to keep FILE_URI approach only.
Started debugging and found that it happens because of calling cleanup function after getting picture. Since in cleanup call file is removed from temporary storage, plugin gives same filename to next picture being available. Logically that should be fine, but here web view playing an evil, picks old image from its cache as URL is same as pervious.
I came with a small fix. Tested that and in my case it worked fine.
I have forked the camera plugin repo and modified method generating temporary file name.
I missed the guideline for parent repository and my commit isn't in required format so I guess my pull request will be declined. (I will update & recreate it as I get some time).
But for now, unless you are planning to remove/add platform (which might clone from master repo loosing the change) you can try this solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With