web stats
SftpConnection - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 11-08-2018, 09:48 AM
StickyBandit's Avatar
StickyBandit StickyBandit is offline
Mirth Guru
 
Join Date: Aug 2013
Location: Home Alone
Posts: 892
StickyBandit is on a distinguished road
Cool SftpConnection

This code seems to not be working after we upgraded to the latest version of
Mirth Connect Server 3.6.1 Built on July 13, 2018 Java version: 1.8.0_181

The destination says SENT and success, but the file does not actually get SFTP'ed

var sftpConn = new Packages.com.mirth.connect.connectors.file.filesys tems.SftpConnection('????', 22, new Packages.com.mirth.connect.connectors.file.FileSys temConnectionOptions(false, "usiisimmu",
("????", new Packages.com.mirth.connect.connectors.file.SftpSch emeProperties() ), 10000);



try { sftpConn.writeFile(('ABC'+DateUtil.getCurrentDate( 'yyyyMMdd')+".hl7"), $('ftp_directory'), false, new Packages.java.io.ByteArrayInputStream(FileUtil.rea dBytes($("data_path_out")+"interfaces/" + ('ABC'+DateUtil.getCurrentDate('yyyyMMdd')+".hl7") ))); }
catch(sftpe) { logger.error($('$')+"SFTP FATAL ERROR: "+sftpe.toString()); }
finally { sftpConn.destroy(); }
Reply With Quote
  #2  
Old 11-08-2018, 10:01 AM
StickyBandit's Avatar
StickyBandit StickyBandit is offline
Mirth Guru
 
Join Date: Aug 2013
Location: Home Alone
Posts: 892
StickyBandit is on a distinguished road
Default

This link from a couple weeks ago, does not work now.

https://github.com/nextgenhealthcare...ec0a4db3aca10b
Reply With Quote
  #3  
Old 11-08-2018, 01:06 PM
StickyBandit's Avatar
StickyBandit StickyBandit is offline
Mirth Guru
 
Join Date: Aug 2013
Location: Home Alone
Posts: 892
StickyBandit is on a distinguished road
Default

I think I can fix this by find the API doc for (or code)

com.mirth.connect.connectors.file.filesystems.Sftp Connection.writeFile(

Apparently this one does not exist anymore

com.mirth.connect.connectors.file.filesystems.Sftp Connection.writeFile(string,string,boolean,java.io .ByteArrayInputStream).
Reply With Quote
  #4  
Old 11-08-2018, 01:09 PM
StickyBandit's Avatar
StickyBandit StickyBandit is offline
Mirth Guru
 
Join Date: Aug 2013
Location: Home Alone
Posts: 892
StickyBandit is on a distinguished road
Default

I found this link...

https://github.com/julianpistorius/m...onnection.java

don't know how old it is?
Reply With Quote
  #5  
Old 11-08-2018, 02:03 PM
agermano agermano is offline
Mirth Guru
 
Join Date: Apr 2017
Location: Indiana, USA
Posts: 530
agermano is on a distinguished road
Default

Please use code blocks. It makes it much easier to read. You can hit the # in the editor tool bar to insert them automatically.

Code:
[CODE]
Your code goes here
[/CODE]
That link you found is old. The official project is owned by nextgenhealthcare: https://github.com/nextgenhealthcare...onnection.java

The forum shortens long links. It looks like your first one didn't work because the abbreviated link was highlighted and copied instead of the actual link address.

Is your fatal error being logged? You probably don't want to catch the error in this case, because when you do, it looks like the problem has been handled. Either take out the catch block (leave the finally block) or throw sftpe in your catch block after you log your message (which will probably end up double logging it.)
Reply With Quote
  #6  
Old 11-08-2018, 03:30 PM
StickyBandit's Avatar
StickyBandit StickyBandit is offline
Mirth Guru
 
Join Date: Aug 2013
Location: Home Alone
Posts: 892
StickyBandit is on a distinguished road
Thumbs up Resolved!

Exactly right on all counts!

(A) Actual link address, now saved in code.
(B) Was not seeing error in mirth dashboard, added throw sftpe; in the catch block.
(C) Mirth added a connectorMap parameter to the
com.mirth.connect.connectors.file.filesystems.Sftp Connection.writeFile signature.

public void writeFile(String file, String toDir, boolean append, InputStream is, Map<String, Object> connectorMap)

After adding connectorMap parameter it seems to be working now.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:27 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Mirth Corporation