Business Rule for SFTP

agent09
New Contributor II

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 to OneStream? Are there libraries readily available in OS for this?

 


So far, we have completed the following.

1. Whitelisting of OS IP from SFTP Server

2. Received SFTP server and credentials needed

 

Thanks!

4 REPLIES 4

NicolasArgente
Valued Contributor

Hi there!
I have not done this for a while, but I remember that you need to contact OneStream support to install winscp.dll from there you will be able to use FTP.
Then in your BR do not forget to add 

'Imports
Imports WinSCP '<--- WinSCPnet assembly is required on the server

And get all your info from there

 

https://winscp.net/eng/docs/library#:~:text=The%20WinSCP%20.,S3%20and%20SCP%20sessions%20from%20.

Cheers

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

NicolasArgente
Valued Contributor

https://winscp.net/eng/docs/library#vbnet

 

Imports WinSCP
 
Friend Class Example
 
    Public Shared Function Main() As Integer
 
        Try
            ' Setup session options
            Dim sessionOptions As New SessionOptions
            With sessionOptions
                .Protocol = Protocol.Sftp
                .HostName = "example.com"
                .UserName = "user"
                .Password = "mypassword"
                .SshHostKeyFingerprint = "ssh-rsa 2048 xxxxxxxxxxx..."
            End With
 
            Using session As New Session
                ' Connect
                session.Open(sessionOptions)
 
                ' Upload files
                Dim transferOptions As New TransferOptions
                transferOptions.TransferMode = TransferMode.Binary
 
                Dim transferResult As TransferOperationResult
                transferResult =
                    session.PutFiles("d:\toupload\*", "/home/user/", False, transferOptions)
 
                ' Throw on any error
                transferResult.Check()
 
                ' Print results
                For Each transfer In transferResult.Transfers
                    Console.WriteLine("Upload of {0} succeeded", transfer.FileName)
                Next
            End Using
 
            Return 0
        Catch e As Exception
            Console.WriteLine("Error: {0}", e)
            Return 1
        End Try
 
    End Function
 
End Class
Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

What type of business Rule did you use, I don't see namespace there.

Thanks

NicolasArgente
Valued Contributor

Hi Tom, It was  extender BR. Do not forget to reference it your assemblies... (I have done that a while ago)

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.