Written by

Enterprise Application Development Consultant at The Ohio State University Wexner Medical Center
MOD
Question Scott Roth · Nov 18, 2016

URL Link Download of Document

We have a couple of systems that send us a URL link to a PDF instead of base 64 encoding it in the HL7 message. Has anyone ever tired to take that URL, and retrieve the file off of the server to save it off somewhere?

Comments

Fabian Haupt · Nov 18, 2016

You can use %Net.HttpRequest to do that.

Something along these lines will work (of course you should checks for errors etc...):

USER>s request=##class(%Net.HttpRequest).%New()

USER>d request.Get("http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf")

USER>s file=##class(%FileBinaryStream).%New()

USER>d file.LinkToFile("/Users/kazamatzuri/temp/test.pdf")

USER>d file.CopyFrom(request.HttpResponse.Data)

USER>w file.%Close()
1
USER>
0
Scott Roth  Nov 21, 2016 to Fabian Haupt

That was very helpful. Thanks. I just now have to add in code to check the file structure and create a new directory if it does not exist to place the PDF in.

0