Discussion

How to read a file in an external FTP system

I understand that we can write the files to an FTP site using Connect-FTP method.

Is there any way to read the files from an FTP site.
Please respond if any of you have experience on this.

Thanks in Advance....

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Comments

Keep up to date on this post and subscribe to comments

April 13, 2012 - 4:10pm

You should write custom Java code as below,

To test this functionality you can create an account in http://www.drivehq.com/ftp/
ftp://USERNAME:PASSWORD@ftp.drivehq.com/
Give the above user name and password to below java code :)

-----------------------------------------
String user="MyUserName";
String password = "MyPassword";
String host="ftp.drivehq.com";
String remoteFile = "My Documents/123.txt";
String localfilename = "C:/ftpdownloads/123.txt";
java.net.URLConnection m_client;
java.net.URL url;

try {

url = new java.net.URL("ftp://" + user + ":" + password + "@" + host + "/" + remoteFile + ";type=i");
m_client = url.openConnection();

java.io.InputStream is = m_client.getInputStream();
java.io.BufferedInputStream bis = new java.io.BufferedInputStream(is);
java.io.OutputStream os = new java.io.FileOutputStream(localfilename);
java.io.BufferedOutputStream bos = new java.io.BufferedOutputStream(os);
byte[] buffer = new byte[1024];
int readCount;

// Reading the file from remote ftp server and write into the local file
while( (readCount = bis.read(buffer)) > 0)
{
bos.write(buffer, 0, readCount);
}
bos.close();
is.close (); // close the FTP inputstream

// User can download this file.

String strFileData = Base64Util.encodeToString(buffer);
String sErrorMessage = tools.sendFile(buffer,remoteFile ,false, null, true);

}

catch (Exception ex)
{
}

Cheers,
Austin Jonny.

April 12, 2012 - 7:48am

I too face the same scenario.... you got any solution..?
Please share if you have any idea on the same.

Thanks in Adv.

December 23, 2013 - 10:55pm

does anyone know of an OOTB way of getting files from FTP/SFTP? seems like Pega should support this functionality, but may be not.

Jay H

July 14, 2015 - 10:58am

Hi,

Please let us know if there is a OOTB way to read the files from FTP instead of writing the java code?

Thanks,

Raviteja.

 

July 14, 2015 - 11:54am

There are several FTP related articles on the PDN including this one for the new FTP Secure (FTPS) feature. Built-in support for SSH FTP (SFTP) is also coming soon.

September 3, 2015 - 5:48pm

The Pega 7.1.9 release added support for SFTP (SSH FTP).

September 30, 2015 - 9:33pm

But the FTP OOTB Method only supports copying from Pega to the Remote location. Whatif we want to do the other way round. Reading from remote location and copying in Pega and reading it?

May 25, 2017 - 4:59am
Response to PinakiBhattacharya

Hi, i need to implement a similar scenario. Have you got the way to implement

My Requirement is the files is available in external file system and i need to save the file into Pega. File can be Word, xsls, txt.

Can you assist?

Thanks in advance. Take care

September 8, 2017 - 10:16am
Response to abhishekk1931

Hi Abhishek, were you able to get the solution for this?. Please acknowledge.

 

Thanks.

September 8, 2017 - 11:57am
Response to GauravA5

Hello!

Thank you for posting your query on PSC. This looks like an inactive post and hence, we suggest you create a new post for your query. Click on the Write a Post button that’s available on the top right pane of this page. Once created, please reply back here with the URL of the new post.

 

We have also sent you a private message opening up a communication channel in case you have any further questions.

 

Thanks,

Marissa | Community Moderator | Pegasystems Inc.

September 9, 2017 - 2:38pm
Response to GauravA5

yes gaurav, i did something simillar please check below post and please let me know if u need more info i would be more than happy to assist.

https://pdn.pega.com/community/product-support/question/migrate-external-file-pega-db-pega-722

 

October 26, 2017 - 2:46am

I am also interested in the approach. Please share.

It seems to me that Pega is missing a valuable integration here. 
@Pega, are you planning to add a read functionallity from (s)FTP to the product soon?

Mod
October 26, 2017 - 6:03am
Response to RSIMONIS

Hello,

To find out information such as product design decisions and timelines, it is best to talk to your Pega Account Executive. Such information can be considered as insider information and is not advisable to be shared on this community.

Regards,

Lochana | Community Moderator | Pegasystems Inc.

October 28, 2017 - 9:08pm
Response to RSIMONIS

https://pdn.pega.com/community/product-support/question/migrate-external-file-pega-db-pega-722

 

Pleas follow above post if anything specific required plaese let me know, i will be glad to help.

November 1, 2017 - 8:34pm

Hi All, did any one find solution to copy csv file from external server to Pega.