Skip to Content
avatar image
Former Member

Portal Abstract Component to download pdf file from SAP EP server

Hi Friends,

I have a requirement where the main java project will run and place all pdf files into /usr/sap/<user-defined-folder>. I need to write an component to read that pdf file and show Open/Save popup to end user to provide options to select.

I have tried portal abstract component and in doContent() method i called another method which is in the same class.

I have provided the EP FTP Path name as "/usr/sap/<user-defined-folder>/<user-defined-sub-folder>/.pdf files". The piece of code is,

if(fileEntry.getName() != null){ response.getWriter().write("File Name:: "+fileEntry.getName()); response.setContentType("application/pdf"); response.addHeader("Content-Disposition", "attachment; filename="+fileEntry.getName()); response.setContentLength((int) fileEntry.length()); fileInputStream = new FileInputStream(fileEntry); responseOutputStream = response.getOutputStream(); int bytes; while ((bytes = fileInputStream.read()) != -1) { responseOutputStream.write(bytes); } }

The problem is, it is taking the entire path name as file name and when it download, it is giving error like the file name is not exist in the folder.

Please help me on how to resolve this issue.

Thanks in advance.

Best regards

Vijay

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Feb 13, 2017 at 01:48 PM

    why dont you use km?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 24, 2017 at 06:00 AM

    Hi Julio,

    Thanks for your reply.

    I have achieved this functionality and now my component is reading the pdf files stored in the server location (FTP).

    BR

    Vijay

    Add comment
    10|10000 characters needed characters exceeded