%CSP.StreamServer not fully downloading file
Hi
I have a few Zen pages, one of which is implementation of
Class GMECC.DocmanConnect.Pages.downloadGPNotOnHub Extends (%ZEN.Component.page, %CSP.StreamServer)
{
ClassMethod GetId()
{
Quit $Get(%request.Data("filepath",1))
}
ClassMethod OnPreHTTP() As %Boolean
{
set filepath = %request.Get("filepath")
set tFs=##class(%Stream.FileCharacter).%New()
set tFs.Filename=filepath
set %response.ContentType = "application/pdf"
do %response.SetHeader("Content-Disposition","attachment;filename="""_$P(filepath,"\",*)_"""")
Do %response.SetHeader("Content-Length",tFs.SizeGet())
Quit $$$OK
}
ClassMethod OnPage() As %Status
{
set myfile = ##class(%File).%New(%request.Get("filepath"))
do myfile.Open("S")
do myfile.OutputToDevice(myfile.SizeGet()) //myfile.OutputToDevice()
quit $$$OK
}
}
And it is called via a hyperlink as follows:
GMECC.DocmanConnect.Pages.downloadGPNotOnHub?filepath=E:\blah\blah.pdf
The resultant file is correctly interpreted as a PDF, given the appropriate file name etc, but is 5Kb smaller
Any thoughts?
Product version: IRIS 2021.1
$ZV: IRIS for Windows (x86-64) 2021.2.1 (Build 654U) Fri Mar 18 2022 06:09:35 EDT