cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Remco Haszing (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CB-9819) navigator.camera.getPicture returns a base64 string, not a data url.
Date Sat, 17 Oct 2015 12:18:05 GMT
Remco Haszing created CB-9819:
---------------------------------

             Summary: navigator.camera.getPicture returns a base64 string, not a data url.
                 Key: CB-9819
                 URL: https://issues.apache.org/jira/browse/CB-9819
             Project: Apache Cordova
          Issue Type: Bug
          Components: Plugin Camera
            Reporter: Remco Haszing
            Priority: Minor


When calling {{navigator.camera.getPicture}} with {{destinationType}} set to {{Camera.DestinationType.DATA_URL}},
the success function is called with the base64 encoded data. [RFC2397|http://tools.ietf.org/html/rfc2397]
specified the data url should have the following format:

{code}data:[<mediatype>][;base64],<data>{code}

I would expect the data to be passed in this format, when a {{DATA_URL}} format is requested.

The example in the README handles this _"bug"_

{code:javascript}
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
    destinationType: Camera.DestinationType.DATA_URL
});

function onSuccess(imageData) {
    var image = document.getElementById('myImage');
    image.src = "data:image/jpeg;base64," + imageData;
}

function onFail(message) {
    alert('Failed because: ' + message);
}
{code}

Instead I suggest the following options:

* base64 encoded:

{code:javascript}
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
    destinationType: Camera.DestinationType.BASE64_ENCODED
});

function onSuccess(imageData) {
    var image = document.getElementById('myImage');
    image.src = "data:image/jpeg;base64," + imageData;
}

function onFail(message) {
    alert('Failed because: ' + message);
}
{code}

* data url:

{code:javascript}
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
    destinationType: Camera.DestinationType.DATA_URL
});

function onSuccess(imageData) {
    var image = document.getElementById('myImage');
    image.src = imageData;
}

function onFail(message) {
    alert('Failed because: ' + message);
}
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message