You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Nikhil Khandelwal (JIRA)" <ji...@apache.org> on 2015/10/23 15:08:27 UTC

[jira] [Updated] (CB-9819) navigator.camera.getPicture returns a base64 string, not a data url.

     [ https://issues.apache.org/jira/browse/CB-9819?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nikhil Khandelwal updated CB-9819:
----------------------------------
    Issue Type: Improvement  (was: Bug)

> 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: Improvement
>          Components: Plugin Camera
>            Reporter: Remco Haszing
>            Priority: Minor
>              Labels: triaged
>
> 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