Download File from server directory


I am trying to write a Java code by which the external type attachment i.e file attachment should be uploaded to a server directory and when that filename is clicked in the directory then that attachment should be downloaded to user's local machine.

Can anybody help me in this?

It will be great if anyone can provide me the java code for the same.


**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.


Keep up to date on this post and subscribe to comments

October 31, 2015 - 6:35am


November 3, 2015 - 4:12am

Thanks for your quick response. But in my case the DownloadFile ativity is not working as I want.

November 12, 2015 - 2:49am

Did you called the baseclass activity?

December 8, 2015 - 1:21am

Try out of the box function

use property-set

param.test = @Default.downloadFile("/tmp/myfile.txt",tools,true) - linux

param.test = @Default.downloadFile("C:\temp\myfile.txt",tools,true) - Windows

January 22, 2016 - 1:48am

Hi All,

I tried @BASECLASS.DOWNLOADFILE and tools.sendFile(bFile, "GeneratedReports.zip", false, null, true) methods in my activity to download files from Server to local environment.

Its working fine when i am running standlone, I mean from Desiner Studio (Run Activity).

Problem : Its not downloading when I am calling the activity from my portal. Tracer, logs all looks good.

Please let me know if I am missing some thing?

January 22, 2016 - 3:13am
  • configure onClick event as Open URL in new window and then
    • call the download activity
  • or please analyse how doAttachmentSingleClick works

February 1, 2016 - 8:38am

How to attach a file from server to work object.  I am having a file in server , gow to attach the file to work object?

February 29, 2016 - 6:23am


Load the File using the PRInputStream in java step of an activity and call the activity some thing like this it may help u.

  PRFile file = new PRFile("testipf.pdf");
PRInputStream inputStream = new PRInputStream(file); 
byte[] b = new byte[(int)file.length()];

  tools.putParamValue("InsHandle","SAE-HRSERVICES-WORK C-64");

HashStringMap params = new HashStringMap();

tools.doActivity(params, null, null);
catch(Exception e)


Hope this works for u, please refer this link too https://pdn.pega.com/generating-pdfs-and-attaching-them-work-objects-or-viewing-them-web-browser