Page 1 of 1

Illegal base64 character in webcam image

PostPosted: Fri Feb 05, 2021 10:24 pm
by pitc
I was attempting to use the webcam package and followed the example as in the webinar ( 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:
Code: Select all

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;

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?

Re: Illegal base64 character in webcam image

PostPosted: Mon Feb 08, 2021 4:29 am
by pitc
OK so I think I have figured it out.
The prefix has to be ignored. So I take the substring after the comma (",") and then convert to a JSImage then I can store that result to a database table column.