Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

$cordovaCamera not returning anything particularily for android 4.4 #1427

Open
Saurabhtomar92 opened this issue Apr 6, 2017 · 0 comments
Open

Comments

@Saurabhtomar92
Copy link

Saurabhtomar92 commented Apr 6, 2017

`console.log(sourceType);
var options = {
quality: 60,
destinationType: Camera.DestinationType.FILE_URI,
encodingType: Camera.EncodingType.JPEG,
sourceType: sourceType,
saveToPhotoAlbum: false
};
console.log(options);
$scope.hidePopup = false;
$scope.functionCalled = true;
$cordovaCamera.getPicture(options).then(function(imagePath) {
console.log(imagePath);
// Grab the file name of the photo in the temporary directory
var currentName = imagePath.replace(/^.*[\/]/, '');

               //Create a new name for the photo
               var d = new Date(),
                   n = d.getTime(),
                   newFileName = n + ".jpg";

               // If you are trying to load image from the gallery on Android we need special treatment!
                if ($cordovaDevice.getPlatform() == 'Android' && sourceType === Camera.PictureSourceType.PHOTOLIBRARY) {
                    window.FilePath.resolveNativePath(imagePath, function(entry) {
                        window.resolveLocalFileSystemURL(entry, success, fail);

                        function fail(e) {
                           console.error('Error: ', e);
                        }

                        function success(fileEntry) {
                            var namePath = fileEntry.nativeURL.substr(0, fileEntry.nativeURL.lastIndexOf('/') + 1);
                            // Only copy because of access rights
                            $cordovaFile.copyFile(namePath, fileEntry.name, cordova.file.dataDirectory, newFileName).then(function(success) {
                               $scope.image = newFileName;
                               $scope.uploadImage('profile_pic', $scope.image);
                            }, function(error) {
                               $scope.showAlert('Error', error.exception);
                            });
                        };
                    });
                } else {
                   var namePath = imagePath.substr(0, imagePath.lastIndexOf('/') + 1);
                   // Move the file to permanent storage
                $cordovaFile.moveFile(namePath, currentName, cordova.file.dataDirectory, newFileName).then(function(success) {
                       $scope.image = newFileName;
                       $scope.uploadImage('profile_pic', $scope.image);
                   }, function(error) {
                       $scope.showAlert('Error', error.exception);
                   });
                }
                // if(!$scope.hidePopup && $scope.functionCalled){
                //     $scope.showAlert('Success','Permited size exceeded');
                // }
            },
            function(err) {
               // Not always an error, maybe cancel was pressed...
            })
    };`

I'm able to get the first console message but not the one printing imagePath & also not getting any error message. Issue is only there in phones having android 4.4.X & on iPhone as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant