Provide a document downloadable link/direct download option for documents stored in Amazon S3 webstorage

We have a requirement to provide a downloadable link for the attachments uploaded in the work objects. Downloadable link needs to be provided as a REST service response which is exposed by Pega. As documents are stored in Amazon S3 there is no direct download link to documents without logging into pega. Below is the sample document location:


Also tried the direct download option by using sendFile() api but this works when service executed from Pega standalone. When we call the service from postman/SOAP UI, document download pop-up appears but there is no content and documents are getting corrupted.

Used below java in service activity to Service activity is



String fileSpec = myStepPage.getString("spec");

PRFile remoteFile = new PRFile(fileSpec);

tools.sendFile( remoteFile, false, null, true );


catch ( Exception e ) {

throw new PRRuntimeException(e);


Requesting inputs if anyone has come across this requirement.




Keep up to date on this post and subscribe to comments

October 1, 2018 - 3:52am

Hi Bharatesh,


Could you please let 's know if you are working in Pega Cloud and which version of Pega have you installed?




October 1, 2018 - 8:15pm
Response to Jakub

Yes Jakub, we are working on Pega cloud and version is Pega 7.3.1


November 5, 2018 - 9:19pm
Response to CHOUGALB

Hi Bharatesh,


we have similar requirement and similar issue, Is your issue fixed? could you please share the approach.

Many Thanks

November 13, 2018 - 8:57am
Response to BharathD6434

Below java is used to read the file from webstorage:

try {
    String fileSpec = tools.getParamValue("DocLocation");
    ClipboardPage streampage = tools.findPage("Test");
    tools.putParamValue("fileSpec", fileSpec);
    PRFile remoteFile = new PRFile(fileSpec);
    PRInputStream pris = new PRInputStream(remoteFile);
    int len;
    byte[] buffer = new byte[1024]; os = new;

    while ((len = != -1) {
      os.write(buffer, 0, len);    
     streampage.putObject("StreamContent", os.toByteArray());
} catch (Exception e) {
    throw new PRRuntimeException(e);


Set these on service page after the java step:

.ContentType = @pxGetMimetypeFromFileName(Param.documentId)

.ContentDisposition = "form-data;filename=\""+Param.documentId+"\""