Ngcordova fileupload camera ios error code 1 -
i have problem ios , ngcordova fileupload. somehow error code 1 in ios dont know why.
this retrieve image camera
$scope.getpicturefromcamera = function(){ var options = { quality: 50, destinationtype: camera.destinationtype.data_url, sourcetype: camera.picturesourcetype.camera, allowedit: false, encodingtype: camera.encodingtype.jpeg, targetwidth: 1000, targetheight: 1000, correctorientation: true, popoveroptions: camerapopoveroptions, savetophotoalbum: true }; $cordovacamera.getpicture(options).then(function(imageuri){ $scope.displayurl = "data:image/jpeg;base64," + imageuri; $scope.pictureurl = "data:image/jpeg;base64," + imageuri; }, function(error){ console.log(error); }); }
this upload image server
createpostwithpicture: function(post, pictureuri){ var url = domain+'/api/v1/statuses/create'; var filepath = pictureuri; var options = { "filekey": "sphoto", "mimetype": "image/jpeg", "params": post } return $cordovafiletransfer.upload(url, filepath, options); },
in android working fine. in ios error following message:
filetransfererror { code = 1; source = data:image/jpeg;base64,....
i cant find solution this. awesome!
seems ios wants camera.destinationtype file_url. changed function
$scope.getpicturefromcamera = function(){ var options = { quality: 50, destinationtype: camera.destinationtype.file_url, sourcetype: camera.picturesourcetype.camera, allowedit: false, encodingtype: camera.encodingtype.jpeg, targetwidth: 1000, targetheight: 1000, correctorientation: true, popoveroptions: camerapopoveroptions, savetophotoalbum: true }; if(device.platform == "android"){ options.destinationtype = camera.destinationtype.data_url; } $cordovacamera.getpicture(options).then(function(imageuri){ if(device.platform == "android"){ $scope.displayurl = "data:image/jpeg;base64," + imageuri; $scope.pictureurl = "data:image/jpeg;base64," + imageuri; } else if(device.platform == "ios"){ $scope.displayurl = imageuri; $scope.pictureurl = imageuri; } }, function(error){ console.log(error); }); }
Comments
Post a Comment