Direct writing to SFTP server in BIDS

0 votes
asked Mar 5, 2012 by rdragstedt (460 points)
edited Mar 6, 2012

Hello,

I have a BIDS 2005 project, and I've been able to successfully open a connection to a SFTP server and put a file there using Rebex after generating the text file locally. However, what I'd really like to do would be:

  1. Open a connection to the sftp server
  2. Write the text file directly to the location
  3. Close the connection to the sftp server

However, in BIDS it won't let me use a ftp://ftp2... location for the destination file.

Any advice?

Thanks!

Applies to: Rebex SFTP

1 Answer

0 votes
answered Mar 6, 2012 by Jan Sotola (16,920 points)
edited Mar 6, 2012

I'm not sure if I undestand your question completely. I think you probably need to upload a file from a stream - you can do it using following code:

// create client, connect and log in 
Sftp client = new Sftp();
client.Connect(hostname); 
client.Login(username, password);

// upload a text using a MemoryStream 
string message = "Hello from Rebex SFTP for .NET!";
byte[] data = System.Text.Encoding.Default.GetBytes(message);
System.IO.MemoryStream ms = new System.IO.MemoryStream(data);
client.PutFile(ms, "message.txt");

(the code has been taken from the SFTP Tutorial)

Anyway, don't use "ftp://ftp2.domain.com" for a hostname parameter in Connect method. -The hostname is only the "ftp2.domain.com" (without the "ftp://").

If you need more advice, please write again.

...