Question
· Feb 14

Sending a file in HTTP response

 

Hi Guys,

 

I’ve the below service that receives a request from a client requiring a pdf file to be sent back for printing.

Basically in this method I’m receiving a message “Yes” and if so I need to determine the length and put it in the Content-Length: or File-Length: fields and then append the byte block to the end of the 200 OK reply so they can print it

Any idea on how to do that?

 

  Include MSDSInclude
Class SX3.Production.HTTP.GetPSRequest Extends Ens.BusinessService [ ClassType = "", ProcedureBlock ]
{
Parameter ADAPTER = "EnsLib.HTTP.InboundAdapter";
Method OnProcessInput(pInput As %Stream.TmpCharacter, Output pOutput As %CharacterStream) As %Status
{
                    Set pOutput=##class(%GlobalCharacterStream).%New()
                    Set tSC2=##class(Ens.Util.JSON).JSONStreamToObject(pInput,.tJsonPayload2)
        printReq=tJsonPayload2."PrintRequest"
        If (printReq = "Yes")
        {
                     //get the content of C:/Temp/myfile.pdf and append it to the 200 Ok response
                    }
     Do pOutput.Flush()
     Quit $$$OK
}
}

Product version: Ensemble 2018.1
Discussion (1)1
Log in or sign up to continue