Upload File from WebCore to XData Service

Not sure if there is an example anywhere, but what parts are you interested in?

I kinda do something like this, uploading a file to the XData server. The gist of it is like this.

WebCore:

  1. Create a WideString variable containing the Base64-encoded data.
  2. eg: SendFile := Window.BtoA(SomeFile); where SendFile is a WideString.
  3. Not clear how you get the SomeFile in there, but probably not too hard.
  4. Make usual call Response := await(Client.RawInvokeAsync(Service,[SendFile]));

XData:

  1. Service should be setup with [HttpPost] so that SendFile can be arbitrarily large.
  2. Use TNetEncoding.Base64.Decode from SysUtils.NetEncoding unit to decode to stream.
  3. In my case, I just dump the file directly into a database still base-64 encoded.
2 Likes