Hi!
I try to load a TWebDataset and after editing to save a picture, but upon saving I get this error "Tainted canvases may not be exported".
To load I use this code:
procedure TfrmEditor.wdsPobudaAfterOpen(DataSet: TDataSet);
begin
imgSlika.Url := connServer.URL + '/pobuda('+wdsPobuda.FieldByName('Id').AsString+')/Slika';
end;
To save I use this code:
procedure TfrmEditor.wdsPobudaAfterApplyUpdates(Sender: TDataSet;
Info: TResolveResults);
begin
UpdatePicture;
end;
procedure TfrmEditor.UpdatePicture;
var
xhr: TJSXmlHttpRequest;
P: integer;
b64: string;
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'));
b64 := imgSlika.Base64Image;
P := Pos(',', b64);
xhr.send(Base64ToArrayBuffer(Copy(b64, P+1, Length(b64))));
end;
I really don't need to save the picture (it is not changed) but if I don't save it explicitly, it is deleted after ApplyUpdate. TWebDataset does not work as TAureliusDataset (which updates just the changed fields), so I need to call UpdatePicture.
So the question is - how do I display a picture in a "detail" window (where te user changes some data, but not the picture)and the save it back to the server?
Hope I have been clear, because sometime the errors are difficult to explain :)