Handling blob fields

Hello all, 


could you show me with a short example code how to access correctly MSSQL blob fields (memo and image types). I want use XDATA + WEB CORE with dbAware web data controls.

Thanks!

Hello,


 Blobs are returned as proxied values in XData. It means the field name (JSON property) comes as "propname@xdata.proxy" and its content is a relative URL for the actual blob content. Here is an example on how to retrieve such content:



procedure TForm1.WebButton1Click(Sender: TObject);
var
  xhr: TJSXmlHttpRequest;


  procedure _Load;
  begin
    WebMemo1.Lines.Text := xhr.responseText;
  end;


begin
  xhr := TJSXMLHttpRequest.new;
  xhr.open('GET',
    XDataWebConnection1.URL + '/' +
    string(TJSObject(XDataWebDataset1.CurrentData)['Description@xdata.proxy'])
  );
  xhr.overrideMimeType('text/plain; charset=utf-16');
  xhr.addEventListener('load', @_Load);
  xhr.send;
end;

Hello Wagner,


it works, thanks for quick help! Another question: how do I process if response is binary data (picture or other streams). Sorry I am absolute beginner in XData... :-)

Zoltan Racz

It depends more on what do you want to do with the binary data? The process is the same, it's just handling the content that differs, and that depends on what you want to do with the content.