@Teravito wrote:
Hello I'm having some troubles with Android uploading photos from the gallery to my server, the code works in iOS (Camera & Library) but in Android only the Camera works fine.
Am I doing something wrong?
$scope.newObjectPhotoLibrary = function(relationIndex)
{
if (!isMaxNumbOfObjects())
{
var options = {
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
quality: 50,
allowEdit: true,
targetWidth: 350,
targetHeight: 350,
maximumImagesCount: 1
};
$cordovaCamera.getPicture(options).then(function(imageData) {
var name = imageData.substr(imageData.lastIndexOf('/') + 1);
var canonicalName = $rootScope.replaceDots(name);
var object = {value: canonicalName, type:"image", path: imageData};
pushObjectToRelation(object, relationIndex);
}, function(err) {
$ionicPopup.alert({
title: 'Error',
content: 'There was an error loading the image'
});
});
}
}var options = {
fileKey: object.value,
fileName: object.path.substr(object.path.lastIndexOf('/') + 1),
chunkedMode: false,
};
// console.log(options);
$cordovaFileTransfer.upload(url, object.path, options)
.then(function(result) {
service.getUser()
.then(function(jsonData)
{ // success
deferred.resolve(data);
}, function(jsonData)
{ // errordeferred.reject(data); });
}, function(err) {
// console.log(JSON.stringify(err));
deferred.reject(err);
}, function (progress) {});
Posts: 3
Participants: 2