How to Get the "RealData" out of a stream

If I try to read data by a TStream I got also the the meta data.

    [Route('/participantBadge/{participantId}')]
    [HttpPatch] function participantBadge( participantId:TCVSObjectId;
                                          [fromBody]  Badge:TStream):TCVSObjectId;

Is there a framework function to get only the binary data?
I can "delete" the chars until line 4 and the lines at the end but this is not very error prof.

Best regards

Hi,
I use Sparkle classes to handle incoming TStream object, similar to your interface.
In the Sparkle user guide search for "Handling Multipart Content", that will help you extracting what you want.

Thank you

Looks that the TMultipart can not handle this. I got Invalid media type. The file is uploaded via SwaggerUI. May be that the swaggerUI handle this different than TMS is expecting this ;-)

I dont ask why is it so magic, but it works

    Reader := TMultipartFormDataReader.Create(TXDataOperationContext.Current.Request.ContentStream,
                                              TXDataOperationContext.Current.Request.Headers.Get('content-type') );
    Badge := TMemoryStream.Create;
    Reader.Next;
    Reader.ContentToStream(Badge);
    

1 Like