BRENT JOYCE
Posts: 0
Joined: Tue May 19, 2015 9:08 am

Android Photolibrary

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?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Android Photolibrary

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

BRENT JOYCE
Posts: 0
Joined: Tue May 19, 2015 9:08 am

Android Photolibrary

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'});
Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Android Photolibrary

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

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

BRENT JOYCE
Posts: 0
Joined: Tue May 19, 2015 9:08 am

Android Photolibrary

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Android Photolibrary

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...

Return to “Issues”