Created
April 1, 2016 13:36
-
-
Save sidthesloth92/d12d4e4c4b65ef9b0619adff9f4763db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yourModule.controller('FileController', function($scope, $cordovaCamera, $cordovaFile) { | |
$scope.fileName = ""; | |
$scope.uploadPicture = 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: false, | |
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, sourceFileName).then(function(success) { | |
$scope.fileName = cordova.file.dataDirectory + sourceFileName; | |
}, function(error) { | |
console.dir(error); | |
}); | |
}, function(err) { | |
console.log(err); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment