Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
Description
When calling navigator.camera.getPicture with destinationType set to Camera.DestinationType.DATA_URL, the success function is called with the base64 encoded data. RFC2397 specified the data url should have the following format:
data:[<mediatype>][;base64],<data>
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"
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); }
Instead I suggest the following options:
- base64 encoded:
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); }
- data url:
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); }