on 07-26-2007 7:37 AM
Hi everybody,
Can you please tell me how to use FileDownload and FileUpload functionality in Webdynpro. we want to Upload a file in a folder in server from local machine and once file is Uploaded then it should be available for downloading.
I am working on NW04 not on NW04s so please tell me according to that.
thanks & regards....
Gaurav Makin
Solved
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
First of all there is no Resource property in NW04 FileUpload UI element. Resource property is in NW04s. So u have to use a context of binary type and bind it to data property of FileUpload UI element.
Refer this doc further it will help u..
<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/202a850a-58e0-2910-eeb3-bfc3e081257f">Upload and Download in NW04</a>
Regards
Puneet
Message was edited by:
Armin Reichert
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Makin,
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Makin,
Use this code in action button for upload a file
Here up is a context attribute of type "com.sap.ide.webdynpro.uielementdefinitions.Resource"
It is to be bind with upload UI element property called "resource"
InputStream text = null;
int temp = 0;
try
{
File file = new File(wdContext.currentContextElement().getUp().getResourceName());
FileOutputStream op = new FileOutputStream(file);
if(wdContext.currentContextElement().getUp()!=null)
{
text = wdContext.currentContextElement().getUp().read(false);
while((temp=text.read())!=-1)
{
op.write(temp);
}
}
op.flush();
op.close();
String path = file.getAbsolutePath();
wdComponentAPI.getMessageManager().reportSuccess(path);
}
catch(Exception e)
{
e.printStackTrace();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gaurav,
See this:
Answers everything about uplaoding and downloading files in web dynpro.
There is a section for 04 also in the link.
Regards,
Ashwani Kr Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ashwini,
Thanks for your reply but there is one thing i want to know that after uploading the file where we can find that file i.e. where it is saved.
Can we save it in our own folder on the server.
And also tell me how to Download the same file which is being Uploaded.
thanks & regards...
Gaurav
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.