cancel
Showing results for 
Search instead for 
Did you mean: 

Link To URL

sid-desh
Advisor
Advisor
0 Kudos

Hi,

I have a PDF file to which i need to provide a link in my view. For that i am using a LINK TO URL UI element. What i have found is that i can place the PDF file in the directory

C:\usr\sap\C11\JC00\j2ee\cluster\server0\temp\webdynpro\web

i believe this is the same path as http://<localost>:<port>/wedynpro/resources

1. Am i correct in assuming that for providing a link to the PDF file the directory location is correct.

2. If the location is correct i want that the user be able to access the file only through the link that i have given and not by directly typing the URL in the browser ie http://<localost>:<port>/wedynpro/resources/FILENAME.PDF

How can i achieve this. As of now i am not able to prevent this.

3. Also when the cursor is taken to the Link provided in the view the complete file path is displayed in the status bar. I want to restrict this also. I dont want the user to see this file location.

Please give suggestions on these points

Thanks and Regards

Sidharth Deshpande

Accepted Solutions (0)

Answers (1)

Answers (1)

htammen
Active Contributor
0 Kudos

Hi Sidharth,

use the FileDownload control. This uses a binary context attribute to send the file to the client. The context attribute can be filled with the data from your pdf file which can be located anywhere at your server (or in your network).

So the user can´t acces it via a url.

Regards

Helmut

sid-desh
Advisor
Advisor
0 Kudos

Hi Helmut,

As the file was already available we were thinking of providing direct link to the same.

However if you suggest reading a file into context please do let me know that for reading the file where should the file be located in the directory structure and also the API involved in reading the PDF file.

Please give your suggestions on the above.

Regards

Sidharth

htammen
Active Contributor
0 Kudos

Hi,

as I understood you want to prevent users from getting the file by typing the direct link in their browser. That´s why I suggested using the FileDownload control.

The file can be located in any folder that is available by the Web AS and here is a very simple code example to fill the context attribute.

String fileName = "C:

tmp

private.pdf";

try{

FileInputStream in = new FileInputStream(fileName);

ByteArrayOutputStream out = new ByteArrayOutputStream();

int length;

byte[] part = new byte ;

while ((length = in.read(part)) != -1) {

out.write(part, 0, length);

}

in.close();

IPrivateView1.IRootElement element = wdContext.currentRootElement();

element.setFileDownload(out.toByteArray());

}catch(IOException e){

// handle Exception

}

In my example there is a value node "root" with a binary value attribute "FileDownload"

Hope that will help you.

Helmut