#1 2014-04-29 07:32:15

LarsS
Member
Registered: 2014-04-25
Posts: 4

Best way for a service to return blob data

Hi,

What is the best way in mORMot to return blob data from a Rest service?

The clients will be either Delphi or Ajax and once the data has been received they will store the blob data as a file. On the server side I have the data in a TStream or in a DB field.

My current idea is to use RawByteString like this:

  procedure GetBlobData(const DataID: Integer; out FileName: string; out Data: RawByteString);

If possible I would also like to compress the data in a way that both client types can handle, but I have no idea how to do that....

Pointers are welcome :-)

br Lars

Offline

#2 2014-04-29 07:54:13

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,207
Website

Re: Best way for a service to return blob data

Please see "Custom returned content" paragraph in the latest SAD 1.18 pdf.
It is always a good idea to check out the latest version of the documentation first.
smile

In short, you use a TServiceCustomAnswer function result, which allows to return any content, including BLOB.
This solution will be perfectly RESTful - you can even assign this URI to an image object in the HTML DOM.

Offline

Board footer

Powered by FluxBB