TWebImageContainer Error

Hi!


I want to resave a previously loaded picture. The picture has been only loaded to a TWebImageContainer and not changed. When I try to execute this code:



procedure TFViewPobudaEdit.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', DMConnection.ApiConnection.URL+'/'+string('pobuda('+PobudaDataSet.FieldByName('Id').AsString+')/Slika'));
  xhr.send(Base64ToArrayBuffer(imgSlika.Base64Image));
end;


I get this error

Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.
    at getBase64Image (http://localhost:8000/Admin/Admin.js:17183:11)
    at Object.GetBase64Image (http://localhost:8000/Admin/Admin.js:17187:9)
    at Object.GetBase64Img (http://localhost:8000/Admin/Admin.js:20774:39)
    at Object.UpdatePicture (http://localhost:8000/Admin/Admin.js:59526:51)
    at Object.PobudaDatasetAfterApplyUpdates (http://localhost:8000/Admin/Admin.js:59425:12)
    at Object.cb [as FAfterApplyUpdates] (http://localhost:8000/Admin/Admin.js:222:26)
    at Object.DoAfterApplyUpdates (http://localhost:8000/Admin/Admin.js:37795:49)
    at Object.ResolveUpdateBatch (http://localhost:8000/Admin/Admin.js:37446:12)
    at Object.cb [as FOnResolve] (http://localhost:8000/Admin/Admin.js:222:26)
    at Object.CheckBatchComplete (http://localhost:8000/Admin/Admin.js:56249:58)

What am I doing wrong?

I'm not sure what you mean with TWebImageContainer as we do not have such control.

I will need more details, more context, code used to be able to reproduce this & investigate.