#1 2020-12-15 18:59:00

leus
Member
Registered: 2012-09-05
Posts: 79

Blob to TStream?

Given the following class:

TMyObj = class(TSQLRecord)
  private
    FBody: TSQLRawBlob;
  published
    property Body: TSQLRawBlob read FBody write FBody;
  end;

I want to store an arbitrary stream, that I receive from somewhere else.

AStream.Position := 0;
MyObj.Body := StreamToRawByteString(AStream);

And to retrieve:

AStream := RawByteStringToStream(obj.Body);
AStream.Position := 0;

Is this the right way to save a stream to a blob? Does this work for binary files?

Last edited by leus (2020-12-15 19:24:01)

Offline

#2 2020-12-16 07:28:39

pvn0
Member
From: Slovenia
Registered: 2018-02-12
Posts: 211

Re: Blob to TStream?

the answer is yes to both questions.

Offline

Board footer

Powered by FluxBB