Skip to Content
0

Portal Abstract Component to download pdf file from SAP EP server

Feb 10, 2017 at 09:51 AM

65

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Julio Alberto Martinez Real Feb 13, 2017 at 01:48 PM
0

why dont you use km?

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 24, 2017 at 06:00 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded