Problem to copy image Ionic


#1

Hello guys! i’m trying take a picture and move for a folder. But doesn’t work…
Veja meu código.

	$scope.takePicture = function(){
			var options = {
				      quality: 50,
				      destinationType: Camera.DestinationType.FILE_URI,
				      sourceType: Camera.PictureSourceType.CAMERA,
				      allowEdit: true,
				      encodingType: Camera.EncodingType.JPEG,
				      targetWidth: 1024,
				      targetHeight: 768,
				      popoverOptions: CameraPopoverOptions,
				      saveToPhotoAlbum: true,
				      correctOrientation: true
		    };

		    $cordovaCamera.getPicture(options).then(function(sourcePath) {
				var sourceDirectory = sourcePath.substring(0, sourcePath.lastIndexOf('/') + 1);
				var sourceFileName = sourcePath.substring(sourcePath.lastIndexOf('/') + 1, sourcePath.length);

				console.log("Copying from : " + sourceDirectory + sourceFileName);
				console.log("Copying to : " + cordova.file.dataDirectory + sourceFileName);
				$cordovaFile.copyFile(sourceDirectory, sourceFileName, cordova.file.dataDirectory).then(function(success) {
				$scope.plant.photo = cordova.file.dataDirectory + sourceFileName;
				// console.dir(success);
		      }, function(error) {
		         console.dir(error);
		      });

		    }, function(err) {
		         console.log(err);
		    });
	};

The output
Copying from : file:///storage/emulated/0/Android/data/com.ionicframework.plant799744/cache/1484759727792.jpg
Copying to : file:///data/data/com.ionicframework.plant799744/files/1484759727792.jpg

But the file file:///data/data/com.ionicframework.plant799744/files/1484759727792.jpg
doest`s work… is broken… =(

nothing is showing