[
https://issues.apache.org/jira/browse/CB-9819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14970939#comment-14970939
]
Remco Haszing commented on CB-9819:
-----------------------------------
This will be a breaking change. I suggest this should be implemented for the
next major version, as major version changes may contain breaking changes
according to semver.
> 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: [email protected]
For additional commands, e-mail: [email protected]