Question
· Jun 9, 2017

Invoking EnsLib.FTP.OutboundAdpter from Object Script

I have a case where I am creating a PDF file from an Encoded String, and I need to transfer this file over to another server. I was wondering since this is PDF file if I could just invoke the FTP.OutboundAdapter within my Object script that is creating the PDF from the encoded string. Is this possible? Does anyone have an examples of using EnsLib.FTP.OutboundAdpater within their Object Script?

Thanks

Scott Roth

Integration - Interfaces

The Ohio State University Wexner Medical Center

Discussion (5)1
Log in or sign up to continue

I took your suggestion about using %Net.FtpSession to transfer the file back and forth between the two boxes, however I am running into an issue trying to ftp.Store the file. Can I have a second pair of eyes take a look at this to see what I am doing wrong?

 

ClassMethod DecodeBase64HL7ToFileFaxing(base64 As %Stream.GlobalBinary, Ancillary As %String, FileName As %String) As %String
{
set ftp=##class(%Net.FtpSession).%New()
if 'ftp.Connect("xxxxx","xxxxx","xxxxxx") $$$LOGINFO("Unable to connect to inteng11") quit



set Oref = ##class(%FileBinaryStream).%New()
set Oref.Filename = FileName

Do base64.Rewind()

While 'base64.AtEnd {
     set ln = base64.ReadLine()
    set lnDecoded = $system.Encryption.Base64Decode(ln)
do Oref.Write(lnDecoded)
}
if 'ftp.SetDirectory("/home/egate/Scott") $$$LOGINFO("Unable to change directory") quit
If 'ftp.Store(Oref,stream) $$$LOGINFO("Unable to write file") quit
if 'ftp.Logout() $$$LOGINFO("Failed to logout") quit

}

 

Thanks

I'd start without base64 decode just to check how ftp works.

I think this would be enough to work (1st argument in Store is a full filename and second is a stream you want to put there):

ClassMethod DecodeBase64HL7ToFileFaxing(base64 As %Stream.GlobalBinary, Ancillary As %String, FileName As %String) As %String
{
    set ftp=##class(%Net.FtpSession).%New()
    if 'ftp.Connect("xxxxx","xxxxx","xxxxxx") $$$LOGINFO("Unable to connect to inteng11")
    if 'ftp.Store(FileName, base64) $$$LOGINFO("Unable to write file")
    if 'ftp.Logout() $$$LOGINFO("Failed to logout")
    quit $$$OK
}