http REST w/an application/octet-stream response

Posted by Tim Kuehn on 27-Jul-2017 09:01

I have a use-case where I'm sending an REST call to a server to generate a PDF document.

The document is returned in streaming format as an application/octet-stream. 

The "entity" class appears to hold that response in an OpenEdge.Core.ByteBucket instance.

I haven't found any documentation on the ByteBucket class which leads to me asking here - is there a way to get the data out of that instance and into a PDF file? 

All Replies

Posted by Tim Kuehn on 27-Jul-2017 09:03

I've done some more exploring and this gets me a copy of the PDF I'm looking for:

oPDFBucket = CAST(oResponse:Entity, OpenEdge.Core.ByteBucket).
oPDFMemptr = oPDFBucket:GetBytes().   

oFileOutput = NEW FileOutputStream("c:\tmp\bol.pdf").
oFileOutput:Write(oPDFMemptr:Value, 1, oPDFMemptr:Size).
oFileOutput:Close().

Posted by Peter Judge on 27-Jul-2017 09:26

Just for the record:
 
A ByteBucket is a (basically) dynamically-sized memptr.
 
An OpenEdge.Core.Memptr is a OOABL wrapper/façade around a primitive  MEMPTR that you can get by calling GetBytes() on a ByteBucket instance. It has a fixed size.
 
 
 
 
 

This thread is closed