fabriciocolombo / delphi-rest-client-api

A Delphi REST client API to consume REST services written in any programming language.
Apache License 2.0
380 stars 182 forks source link

How to deal with binary data (blob)? #52

Closed patrick-heuer closed 8 years ago

patrick-heuer commented 9 years ago

I have a TClientDataset having a field containing binary data (TBlobField). I´m using "TResource.GetAsDataSet" and "TResource.GetAsDataSet(ADataSet: TDataSet)", but it seems for me not to be possiblt to marshal binary data from JSON...

Any idea´s how to deal with binary data? Example?

Thx!

RobertoSchneiders commented 9 years ago

Hi @PKrause79

AFAIK, JSON does not support binary.

I don't remember doing anything like this, so, I'm not sure I can help you.

The first thing that comes to my mind was use a BASE64 serialization and then put it on the JSON. I think the SuperObject has some "Stream" methods, which may help you too.

http://stackoverflow.com/questions/1443158/binary-data-in-json-string-something-better-than-base64 http://blog.marcinbudny.com/2014/02/sending-binary-data-along-with-rest-api.html#.VemEqfnBzRY