Created
June 24, 2017 10:52
-
-
Save wayanjimmy/43b05c69005cae84f0cc473aecb6da1a to your computer and use it in GitHub Desktop.
Ionic file upload gallery
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
$log.info('imagePath', imagePath); | |
if (imagePath.substring(0, 21) == 'content://com.android') { | |
var photoSplit = imagePath.split('%3A'); | |
var imageURI = | |
'content://media/external/images/media/' + photoSplit[1]; | |
window.FilePath.resolveNativePath(fileEntry.nativeURL, function(response) { | |
upload(response); | |
$log.info(response); | |
}); | |
window.resolveLocalFileSystemURL(imageURI, function(fileEntry) { | |
$log.info(fileEntry); | |
var namePath = fileEntry.nativeURL.substr(0, fileEntry.nativeURL.lastIndexOf('/') + 1); | |
$cordovaFile | |
.moveFile( | |
namePath, | |
fileEntry.name, | |
cordova.file.dataDirectory, | |
newFileName | |
) | |
.then( | |
function(success) { | |
upload(newFileName); | |
$scope.newFileName = success; | |
}, | |
function(error) { | |
} | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment