Hi!
I've made a windows with a TWebCamera component that adds a picture to the XData structure. The problem I encounter is this:
New.pas:271 Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
at Base64ToArrayBuffer (http://localhost:8000/Okolje24/Okolje24.js:63501:31)
at Object.UpdatePicture (http://localhost:8000/Okolje24/Okolje24.js:63512:16)
at Object.wdsPobudaAfterApplyUpdates (http://localhost:8000/Okolje24/Okolje24.js:63460:39)
at Object.cb [as FAfterApplyUpdates] (http://localhost:8000/Okolje24/Okolje24.js:222:26)
at Object.DoAfterApplyUpdates (http://localhost:8000/Okolje24/Okolje24.js:37121:49)
at Object.ResolveUpdateBatch (http://localhost:8000/Okolje24/Okolje24.js:36772:12)
at Object.cb [as FOnResolve] (http://localhost:8000/Okolje24/Okolje24.js:222:26)
at Object.CheckBatchComplete (http://localhost:8000/Okolje24/Okolje24.js:48829:58)
at Object.OnLoad (http://localhost:8000/Okolje24/Okolje24.js:48962:48)
at Object.cb [as FOnLoad] (http://localhost:8000/Okolje24/Okolje24.js:222:26)
The code I use to upload the image is after the ApplyUpdate (So I get the Id of the record):
procedure TfrmNew.wdsPobudaAfterApplyUpdates(Sender: TDataSet; Info: TResolveResults);
begin
UpdatePicture;
Result := wdsPobuda.FieldByName('Id').AsInteger;
ModalResult := mrOk;
end;
procedure TfrmNew.UpdatePicture;
var
xhr: TJSXmlHttpRequest;
function Base64ToArrayBuffer(str: string): TJSArrayBuffer;
var
BufView: TJSUInt8Array;
BinaryString: string;
I: Integer;
begin
BinaryString := window.atob(str);
Result := TJSArrayBuffer.New(Length(BinaryString));
BufView := TJSUInt8Array.New(Result);
for I := 0 to Length(BinaryString) - 1 do
BufView := TJSString(BinaryString).CharCodeAt(I);
end;
begin
xhr := TJSXMLHttpRequest.new;
xhr.open('PUT', connServer.URL+'/'+string('pobuda('+wdsPobuda.FieldByName('Id').AsString+')/Slika'));
xhr.send(Base64ToArrayBuffer(camMain.SnapShotAsBase64));
end;
I checked the string and I don't know how to resolve the error, please help.