Illegal base64 character in webcam image
Posted: Fri Feb 05, 2021 10:24 pm
I was attempting to use the webcam package and followed the example as in the webinar (https://www.youtube.com/watch?v=d2ZUVOjmI-w&feature=emb_logo) when I came across this error when trying to save the captured image from the webcam.
In developer the data returned is of type {JSMedia} has these characters at the beginning:
The URI format is data:[<media type>][;base64],<data>
the handler for the capture call back is (where the var is a form var defined as media):
I tried to convert it to a byte array:
and get this error message:
The ascii for 3a is the colon (:). I scanned the <data> part and did not find any more.
So does this mean the webcam component is incorrect or is it the utils method that is out of date for JSMedia type?
I am using servoy 2020.12.1 and the latest package: svywebcam (1.0.4)
I have no insight as to how to fix this issue.
Any ideas?
Tom
In developer the data returned is of type {JSMedia} has these characters at the beginning:
- Code: Select all
"data:image/jpeg;base64,/9j/4AA...."
The URI format is data:[<media type>][;base64],<data>
the handler for the capture call back is (where the var is a form var defined as media):
- Code: Select all
function getBase64Data_from_webcam_4(data) {
vf_cam_image = data;
return;
}
I tried to convert it to a byte array:
- Code: Select all
var img_byte_array = utils.base64ToBytes(vf_cam_image)
and get this error message:
exception= java.lang.IllegalArgumentException: Illegal base64 character 3a
The ascii for 3a is the colon (:). I scanned the <data> part and did not find any more.
So does this mean the webcam component is incorrect or is it the utils method that is out of date for JSMedia type?
I am using servoy 2020.12.1 and the latest package: svywebcam (1.0.4)
I have no insight as to how to fix this issue.
Any ideas?
Tom