Yuri Marx · Feb 2, 2022 1m read

Download File REST API Operation

If your REST API need return a file to the client download, this is the source code that you could write (P.S.: extracted from the question and its responses):

Set %response.ContentType = "image/jpeg"
Do %response.SetHeader("Content-Disposition","attachment;filename=""test.jpg""")
Set %response.NoCharSetConvert=1
Set %response.Headers("Access-Control-Allow-Origin")="*"
Set stream=##class(%Stream.FileBinary).%New()
Set sc=stream.LinkToFile("/opt/irisbuild/output/test.jpg")
Do stream.OutputToDevice()
Set tSC=$$$OK
0 507
Discussion (0)1
Log in or sign up to continue