Page 1 of 1

Android Photolibrary

Posted: Tue Nov 03, 2015 12:09 am
by BRENT JOYCE

I successfully implemented upload of images from Camera and Phone using the Camera and CordovaFileUpload Services on an iPhone. However I can only get images to upload if the Camera is the source on an Android. I get "undefined" if I set Photolibrary as the source. On an Android the Camera Service returns file:///..... but should be htttp://.... Has anyone come across this problem? If so how did you resolve it?


Android Photolibrary

Posted: Tue Nov 03, 2015 6:03 pm
by Serhii Kulibaba

Hello Brent,

Camera service returns URI to the local file in the imageURI parameter, so, file:/// is correct value.

Please use parameter imageDataBase64 for getting photo in the base64 sting


Android Photolibrary

Posted: Tue Nov 03, 2015 11:49 pm
by BRENT JOYCE

Hi Sergiy, I have also tried using imageDataBase64 based on webupload. It works fine in the Appery test environment but fails on the Android device. Its fails in the code shown below blob constructor. Apparently the blob constructor is not supported by Android.

/*** Uploads a binary file (base64) using browser API, without Cordova ***/
function uploadBinaryHelper(datasource, imageBase64Data, name, type) {

Code: Select all

 if (imageBase64Data) { 
     var byteCharacters = atob(imageBase64Data.substring(imageBase64Data.indexOf(',')+1)); 
     //console.log(byteCharacters); 
     var byteNumbers = new Array(byteCharacters.length); 
     console.log(byteCharacters.length); 
     for (var i = 0; i < byteCharacters.length; i++) { 
         byteNumbers[i] = byteCharacters.charCodeAt(i);  
     } 
     var byteArray = new Uint8Array(byteNumbers); 
     var imageType = type || 'jpeg';  
     var imageName = name || new Date().getTime(); 
     imageType = (imageType == 'png')?imageType:'jpeg'; 
console.log("blob");         
     var blob = new Blob([byteArray.buffer],{type: 'image/' + imageType, endings:'transparent'});

Android Photolibrary

Posted: Wed Nov 04, 2015 8:25 pm
by Serhii Kulibaba

Please specify what device and OS version you use to test.

This link might be useful: http://caniuse.com/#search=blob


Android Photolibrary

Posted: Wed Nov 04, 2015 10:48 pm
by BRENT JOYCE

Galaxy S3 GT-I9300 Android Version 4.3. No console messages are printed after console.log('blob') in the code fragment I provided.


Android Photolibrary

Posted: Tue Nov 10, 2015 11:17 am
by Serhii Kulibaba

As you can see in the link above, Androin 4.3 particulary supports Blob object. But you can use workarounds, e.g.: http://stackoverflow.com/questions/14...