angularjs - Cordova FileTransfer and Cordova Camera -


i'm working in ionic cordova plugins (filetransfer, camera, file, etc).

view - screenshot

on view works great, can show images(camera , gallery) filetransfer error code = 1 when try upload , means file not found. when check app directory (cordova.file.datadirectory , cordova.file.cachedirectory) empty.

camera code:

$scope.takephoto = function(){ var optionscamera = {   quality: 100,   destinationtype: camera.destinationtype.file_uri,   sourcetype: camera.picturesourcetype.camera,   savetophotoalbum: false,   correctorientation: true };  $cordovacamera.getpicture(optionscamera)   .then(function(imagedata){      console.log(imagedata);      var currentname = imagedata.replace(/^.*[\\\/]/, '');     var namepath = imagedata.substr(0, imagedata.lastindexof('/') + 1);     console.log(currentname);     console.log(namepath);     //move cache files     $cordovafile.movefile(namepath, currentname, cordova.file.datadirectory, 't_s'+currentname)       .then(function(successmove){         console.log(successmove);         $scope.imagenes.push('t_s'+currentname);         console.log($scope.imagenes);       }, function(errormove){         console.log(errormove);       });    }, function(errorcamera){     console.log(errorcamera);   })} 

upload code:

$scope.senddata = function() {  var server = config.serverurl() + '/product_image_upload/';  console.log($scope.imagenes); //first image in array var targetpath = $scope.imagenes[0]; var filename = ($scope.imagenes[0]).replace(/^.*[\\\/]/, ''); console.log(targetpath); console.log(filename);  var options = {   httpmethod: 'post',   filekey: 'file',   filename: filename,   chunkedmode: false,   mimetype: 'multipart/form-data' };  var params = {   'filename' : filename, }; //jwt token var headers = {   'authorization': $rootscope.token }; options.headers = headers; options.params = params; console.log(options); $cordovafiletransfer.upload(server, targetpath, options).then(   function(result) {     // success!     console.log('upload ok');     console.log(result);   }, function(err) {     // error     console.log(err);   }, function(progress) {     // constant progress updates     console.log(progress);     $scope.progress = progress;   })} 

i want know, files?


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -