TobiasW
TobiasW

Reputation: 891

phonegap get a valid base64 code from camera or gallery (android)

I want to upload a base64 image to my server, but I can't get a complete base64 Code from the camera or the gallery. My code is the following:

navigator.camera.getPicture(onSuccess, onFail, {
        quality: 100,
        destinationType: Camera.DestinationType.DATA_URL,
        EncodingType: 1
    });

function onSuccess(imageUri) {
    console.log('ImageURI ' + imageUri);
}

When the Code is printed to the console, I copy this code and try to valid it like the guy did in this inactive post, with the same issue as he has. phonegap picture base64 android

It can't be a limit on the console, because I can get complete base64 codes from local images.

I've tried some other qualities too, like 50 or 10.

Upvotes: 0

Views: 128

Answers (1)

Mister Smith
Mister Smith

Reputation: 28168

The fact you are having trouble should make you seriously consider whether you want to b64 the image at all. Modern phones have crazy camera resolutions, 8 Mpixels being normal. Base64 encoding adds 37% more data, so its even worse.

Try with an smaller image, like 100x100, you'll see it working. I'm pretty sure Logcat cannot swallow 8 MB (read here)

Upvotes: 1

Related Questions