cancel
Showing results for 
Search instead for 
Did you mean: 

UploadFiles From Client to Server

Former Member
0 Kudos

Hi friends,

I need to develop a view, which will upload file from client machine to server machine.

I found out a document "Uploading and Downloading Files in Web Dynpro Java" for doing the program.

In this document, upload resources between client and controller context is explained in detail.

My question is how to get the resource(excel file) stored in controller context and save it to local drive('C:' or 'D:' drive).

Please provide me some code sample on this.

Thanks and Regards,

Vijay Babu.

Accepted Solutions (0)

Answers (1)

Answers (1)

sureshmandalapu6
Active Contributor
0 Kudos

Hi Mohamad Shamsulbahri Bin Md Zulkifl ,

For file down load u have to use a UI element as "File download".

u just create context attribute as setdownload_res and file data.

setdownload_res as of type "com.sap.ide.webdynpro.uielementdefinitions.Resource" then bound it to the ui element "resource".

file data as of type "com.sap.tc.webdynpro.progmodel.api.IWDInputStream"

and set calcuclated as true and read only as true.

then in doinit method u just write this code

IWDAttributePointer attr = wdContext.currentContextElement().getAttributePointer("fileData");

IWDResource res = WDResourceFactory.createResource(attr,null,WDWebResourceType.UNKNOWN);

wdContext.currentContextElement().setDownload_res(res);

wdComponentAPI.getMessageManager().reportSuccess(""+c);

after this in the getter method u write this code

IWDInputStream stream = null;

try

{

stream = WDResourceFactory.createInputStream(new FileInputStream(new File("<pathof the file to be download>")));

}

catch(Exception e)

{

e.printStackTrace();

}

return stream;

also look at this thread

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081...

Thanks

Suresh