cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikhil Khandelwal (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-9819) navigator.camera.getPicture returns a base64 string, not a data url.
Date Fri, 23 Oct 2015 13:07:27 GMT

    [ https://issues.apache.org/jira/browse/CB-9819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14970932#comment-14970932
] 

Nikhil Khandelwal commented on CB-9819:
---------------------------------------

This would be a good improvement but it will likely break existing users of the API. I'm not
sure if the benefit is worth the breaking change.

> 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