cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload

Former Member
0 Kudos

Hello all,

Hope you are having a nice time.

I have a requirement to upload a file and then download it.

I have a used a FileUpload UI element which has a predefined UI format. ie an input field and a button.

My Questions are:

1) If i want a link only on my UI page --> Upload. This should open a dialog window of the file selection. (same as FileUpload UI element). Is this possible. Can i link my link element to FileUpload UI without displaying FileUpload UI element onto the webdynpro screen?

2) Suppose i have selected a file from File select dialog using the File Upload element. Now is it that the file is attached to this context element and i can access it later for downloading it?

3) If anser to above question is yes, how do i download the file?

Thnks

Accepted Solutions (1)

Accepted Solutions (1)

former_member185086
Active Contributor
0 Kudos

Hi

1. Link UI is just link a Action So u can't open dialog window for file selection by this,But yes u can open a popup with help of this action further u have to use file Upload UI element for file selection. Yes u can achieve this function without using this , in this case u have to give the file parh at runtime (thats why File Upload UI element is there)

2.No, U have to manually take the content of the file into contest node , further data will there for other operations

3. Take help from this thread which has all your [needs|;

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi Satish,

With regards to file upload, if i have to take content, can it be done for a .doc file also?

Thnks

pravesh_verma
Active Contributor
0 Kudos

Hi Yogesh,

This can take care of .doc file as well. However you have to write a different code in the Parse method for the .doc file. Please refer to these links for reading the doc file. You can add this to the parse method:

http://www.hiteshagrawal.com/java/reading-word-document-in-java

Please check this link as well where I have clearly described the way to perform the FileUpload operation.

I hope this helps you and solve your issue!

Thanks and Regards

Pravesh

Edited by: Pravesh Verma on Mar 23, 2009 2:58 AM

Former Member
0 Kudos

Hi Pravesh,

From the message you have put in last, it says about the File path.

So if my understanding goes correct, since i wll have the path of the file, i can use that same path later to download the same file. Am i correct?

For this path, i can have a string type attribute which holds that value. Correct?

Thnks

pravesh_verma
Active Contributor
0 Kudos

Hi Yogesh,

Yes you are correct. However it will not be a String value. it wil be a resource value from you can extract the file path very easily using the API provided.

I hope this helps! Also please refer to the link which I have posted above. It shows you the way to read a .doc file. You may have to add some external jars for the same. Just check in the link.

If you have any furtehr issues please revert back.

Thanks and Regards,

Pravesh

Former Member
0 Kudos

Hi Pravesh,

With reference to your message with the link:

It talks about a server where the file will be uploaded.

What is the server?

What can be a server in terms of Local Development?

pravesh_verma
Active Contributor
0 Kudos

Hi Yogesh,

Its nothing but a simple FileOutputStream object. You can set the value to this stream. In my case I was using the FileOutputStream to save the resource at my server C:/ directory, therefore I have just documented it that ways!

In terms of local development server will be that place where your applicationis running. That means where the WS is installed. I was having the server at my local machine, however you may have a distributed environment where the WAS is installed to some other system instead of local system.

I hope this is clear! Kindly revert back if you need any further information.

Thanks and Regards,

Pravesh

Former Member
0 Kudos

Hi Pravesh,

So if i understand this correctly,

For local machine, let me say i have selected a folder for uploading my file.

This means that that path will be hardcoded.

For eg C:\Webdynpro\

This means if i am picking up a file from my own system and just copying it to a specific location just to simulate the whole concept.

And then for downloading i again give the same path (hard-coded) and locate the file with file name.

Am i correct?

pravesh_verma
Active Contributor
0 Kudos

Hi Yogesh,

Please note that while uploading a file, you just select the resource from your local machine. Thats is all.. After that during the upload process the file will be uploaded to the server location. Not at your local system (condition apply: If your server is at your local machine then it will upload at your local machine only).

While downloading it will again take the resource path from the server you need not have to hardcode it. You have to use the API's from getting the file location and path.

Please check this help.sap.com link:

http://help.sap.com/saphelp_nw2004s/helpdata/en/42/fdf9c528d45171e10000000a1553f7/frameset.htm

I hope this helps!

Thanks and Regards

Pravesh

Former Member
0 Kudos

Hi Pravesh,

Thats what exactly my doubt was.

What is that server?

What do i need to have it? Is it any service? For eg FTP, etc?

pravesh_verma
Active Contributor
0 Kudos

Hi Yogesh,

No no.. Nothing like FTP etc.. Dear you already have a server. Its the same server where you are deploying your application.

The uploaded file will also go to the same server to a specified folder.

Please understand that all the web applcaition including your webdynpo application runs on WAS which is Web Application Server (This is the same server where you are deploying and running your webdynpro applications).

I hope it is clear now!

Thanks and Regards

Pravesh

Former Member
0 Kudos

Thanks Pravesh.

Let me get back to you post working on this, since am sure there will new doubts.

former_member185086
Active Contributor
0 Kudos

Hi

No, Procedure will different for .doc file ,It was just to inform u that how to upload/download works and taking data from external file and keeping it in context node.

Further, U can take help from this [thread|; will give u detailed insight of understanding this.

Best Regards

Satish Kumar

Answers (1)

Answers (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Yogesh,

Answer to your first question is No. You cannot trigger the upload event on the click of the link to action event. This is not possible.

Regarding the second requirement. This is somewhat achievable. Since you have binded the Upload UI element with some context attribute therefore that valueo f the path exist in the attribute. You can access that path and then write the code of upload by accessing the path from that attribute.

Check these links for file upload:

/people/bertram.ganz/blog/2007/05/25/new-web-dynpro-java-tutorials--uploading-and-downloading-files-in-sap-netweaver-70

Also please check the way in which you have to create the resource attrib ute which needs to be binded:

1) In your view, create a UI element File Upload

2) Create a context attribute say Source of type(com.sap.ide.webdynpro.uielementdefinitions.Resource)

i) Type -


> Click browse

ii) Choose Simple type -


> Click package com.sap.ide.webdynpro.uielementdefinitions

iii) In that package choose Resource and then Click ok

3) Switch to Layout tab, bind the resource property with this context attribute(source)

I hope this helps!

Thanks and Regards

Pravesh

Former Member
0 Kudos

Hi Pravesh,

Thanks a ton for your quick reply. I really appreciate it.

However, i still have some doubts.

1) Over the Link possibility. Let us say, i have a Link UI element and a FileUploadUI element on my screen. FileUpload is not visible on screen. Now on my link action i link upto the FileUpload UI and call up the action (which may be standard of course) which actually calls up the upload file selection window. (I hope i am not sounding too foolish )

2) With regards to the second point, you have mentioned that i will have the path. Is this path the local system file system path?

I am new to dynpro and my understanding is that the FileResource Context attribute which i have createed will hold the file instance itself. So with help of it i can transfer file to an other context attribute (of the same type ofcourse)

Please help!!!!!!!