cancel
Showing results for 
Search instead for 
Did you mean: 

How to download a file from a custom server location?

Former Member
0 Kudos

Hello experts,

I have the following scenario:

A BAPI creates an .exe file and stores it in a custom folder in the server where the portal (and my WD application) is running. This happens once a day.

What I need to do is create a link or button (doesn't matter) so that users can click on it and download this file.

I already checked the file upload - download tutorial (http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081257f;jsessionid=%28J2EE3417500%29ID0774236150DB11016171821629714331End?overridelayout=true) however this one considers the file to be downloaded is stored in the src folder of the project, thus it doesn't really help me.

How can I achieve this? Any suggestions and help will be greatly appreciated.

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

monalisa_biswal
Contributor
0 Kudos

hi Alain,

Use File API to read data from the file. It will return byte array from the file. Set Byte array to the file resouce context attribute.

bind this attribute to the filedownload UI element.

Since you need to read file from the same server where webdynpro application is running, You can give the folder path on the server where the file is located.

try {
			File inputFile =
			new File("C:\\Test\\Test.txt");
 
 
			FileInputStream in = new FileInputStream(inputFile);
			byte b[] = new byte[ inputFile.length()];
			in.read(b);
			in.close();
 
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}

Former Member
0 Kudos

Hi Monalisa,

Thanks for your reply, let me give it a shot and I'll let you know how it goes.

Answers (1)

Answers (1)

0 Kudos

Hi Alain,

You can to get file for java,and cast to byte[] and cast to Resource by byte[],so you can run "IWDResource.download()" to get file for IE.