Subject Re: [IBO] Reading first X Bytes of a BLOB
Author dmarmur2002
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@...> wrote:
>
> At 10:08 PM 11/04/2008, you wrote:
> >Hello!
> >
> >I'm reworking my document handling from the cursed M$-OLE-based crap I
> >wrote previously to something more manageable. I'm going to use MIME
> >multipart/form-data and found a simple parser.
> >
> >Since it is more manageable to put some of the information into fields
> >before the actual files goes in, it would be a huge benefit for the
> >GUI if...
> >
> >...it would be possible to get just the first X bytes of a blob in
> >IBO? In IB_Session@2035 (IBO 4.6A) I can see:
> >
> > repeat
> > GetSegment;
> > until ( Result <> 0 ) and ( Result <> isc_segment );
> >
> >This suggests that even just getting the IB_BlobStream.BlobSize will
> >get the whole blob down the line.
>
> Blob segments aren't meaningful in any data sense. At the client
end they can be used to set fetch and carry options across the network
transport. At the server end, the server pleases itself about how it
partitions the incoming or outgoing byte stream.

I did not mention "segments" in my narrative at all - you are
probably referring to my code quotation.

>
>
> >Maybe the fbclient library can not handle such requests at all, but I
> >suspect otherwise.
>
> A *portion* of a non-text blob has no interpretable meaning, either
to the server or to the client. The first n bytes of a binary blob
are nothing but some unspecifed n bytes of "something".What would you
expect to test or display?

Well, that should be up to *ME* (as in the person who wrote/stored the
BLOB in the first case) to decide. Not? If you dig into the plethora
of filetypes, storage formats and what-not in detail you will find
that headers can be very informative. Since *I* will be creating the
MIME-compliant BLOBs... *I* can also decide what to put "on top". IMHO
this has nothing to do with the server . It is *my* decision entirely.

>
> You can pull a substring of a text blob via your SQL statement, of
course.

Hey! Now we're getting somewhere. This is good - I did not think about
that. Ignore my rant above. I never imagined that FB would allow me to
SUBSTRING a non-text blob. I can do:

SELECT T.ID, T.BLOB_FIELD, SUBSTRING(T.BLOB_FIELD FROM 1 FOR 2048) AS
BLOB_FIELD_PREVIEW
FROM ATABLE T
WHERE T.WHATEVER = :WHATEVER_I_WANT

Thank you Helen - this means that I do not have to use extra fields
and that I do not have to "colour" my database design with client
document handling from different platforms and architectures.

OK - this solves the problem for initial deployment. But I fail to
cast the substring back to a BLOB. Thus - I can not use the neat
features in IBO controls to retrieve the BLOB when the user focuses a
certain control :(

So - I still feel that it should be possible to say

IB_BlobStream := Statement.CreateBlobStream(Statement.Field[1],
bsmRead, {limit fetch to} 2048);

Thanks a lot!

/Dany