cancel
Showing results for 
Search instead for 
Did you mean: 

Uploading the file

lokesh_kamana
Active Contributor
0 Kudos

Hi all,

I had a requirement where i need to download the file which is uploaded by me.

I will explain the things what i have done for uploading.

I have taken a File Upload UI Element.

and binded it with 2 attributes.

this 2 attributes are under the node upload

attr1->string

attr2->binary

1st one is binded to file name property.

2nd one is binded to data property.

WDDOINIT

PrivateWordAppView.IUploadElement Element = wdContext.createUploadElement();

wdContext.nodeUpload().bind(Element);

IWDModifiableBinaryType type = (IWDModifiableBinaryType) wdContext.nodeUpload().getNodeInfo().getAttribute(IPrivateWordAppView.IUploadElement.ATTR2).getModifiableSimpleType();

and i have taken a button upload in the action of the button i have written the following code

String file = wdContext.nodeUpload().currentUploadElement().getAttr1();

String filename = file;

File destinationFile = new File(filename);

FileOutputStream out = new FileOutputStream(destinationFile);

out.write(wdContext.nodeUpload().currentUploadElement().getAttr2());

String path = destinationFile.getAbsolutePath();

wdComponentAPI.getMessageManager().reportSuccess(path);

the path of the file stored ion the server is

/usr/sap/EPD/JC50/j2ee/cluster/server1/<uploaded file name>

Now i want to download the same file from the server.

can any one let me know how to write the code.

Thanks & regards,

Lokesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

You can refer this PDF for file download. This is working fine for me.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/00062266-3aa9-2910-d485-f1088c3a...

I hope this may also help you.

thanx.

Former Member
0 Kudos

Hi,

FileDownload:- With the FileDownload element, the user can download a file. Depending on the selected setting

of the behaviour property, the user can open the file or store it on the local hard disk.

The data source, that is the file to be downloaded is determined by the resource property. To be able to load a

file into the context with the FileDownload element, you need the WDResourceFactory. Insert the following code

into the wdDoInit method:

IWDResource resource = WDResourceFactory.createResource(new byte[<number of bytes>], "<name of the file>",WDWebResourceType.<type of the file>);

wdContext.currentUiResourceElement().setResource(resource);

currentUiResourceElement depicts the context node under which you have created the value attribute resource of type Resource.

Find more details here: http://help.sap.com/saphelp_nw2004s/helpdata/en/c8/32cc6922fb6040a768652aaa0b6879/frameset.htm and in the link posted above.

Rgds,

Anagha

Edited by: Anagha Jawalekar on Nov 13, 2008 9:59 AM