The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.
Forum Discussion
agent09
3 years agoNew Contributor II
Business Rule for SFTP
Hi - we're trying to PULL files from an SFTP server. These will be used for our OneStream load.
Are there any sample BRs that we can reference to facilitate the file transfer from the SFTP server t...
victortei
1 year agoNew Contributor III
My usual setup is a BR that connects to the SFTP, which assures everything related to the login is handled in a single point.
Make sure you include Imports WinSCP in the header.
Here's a sample code:
Imports System
Imports System.Data
Imports System.Data.Common
Imports System.IO
Imports System.Collections.Generic
Imports System.Globalization
Imports System.Linq
Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Imports OneStream.Shared.Common
Imports OneStream.Shared.Wcf
Imports OneStream.Shared.Engine
Imports OneStream.Shared.Database
Imports OneStream.Stage.Engine
Imports OneStream.Stage.Database
Imports OneStream.Finance.Engine
Imports OneStream.Finance.Database
Imports WinSCP
Namespace OneStream.BusinessRule.Extender.SFTP
Public Class MainClass
Public Shared Function SFTPConnection() As SessionOptions
Dim SessionOpts As New SessionOptions
With SessionOpts
.Protocol = WinSCP.Protocol.Sftp
.Portnumber = 22
.HostName = "ftp.XXXXX.XXXXX"
.UserName = "SFTPXXXXX"
.Password ="XXXXXX"
.GiveUpSecurityAndAcceptAnySshHostKey = true
End With
Return SessionOpts
End Function
End Class
End NamespaceThen on my other BR, I'd instantiate that rule and open the connection as usual.
Dim sftpHelper As New OneStream.BusinessRule.Extender.SFTP.MainClass()
Dim FileFound As Boolean = False
Using session As New Session
' Connect
session.Open(sftpHelper.SFTPConnection())
....If you want to do something similar, make sure to reference the connection BR in your Referenced Assemblies.
Related Content
- 2 years ago
- 3 years ago
- 4 years ago