cancel
Showing results for 
Search instead for 
Did you mean: 

How to download an uploaded file?

Former Member
0 Kudos

hi,

I have uploaded a file( jpg ) using FileUpload UI Element.

As far as I know file is uploaded in the Server.

Now is it possible to download that particular file which i have uploaded ?

If so, how to proceed for that ?

Thanx.

Accepted Solutions (1)

Accepted Solutions (1)

Sm1tje
Active Contributor
0 Kudos

What do you mean by: As far as I know? Did you or did you not download it to application server? Meaning, after uploading the file, it is stored in context node which is assigned to your UI element. But did does not mean that is automatically stored on the application server.

Former Member
0 Kudos

hi Micky,

Thanks for the reply and clearing my doubt.

Could you plz let me know how we can upload the file to the Server.

I got the file in the Context Node. So how to proceed further ?

Thanx.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Where do you want to store it on the server? In the filesystem, in the database, or in the MIME Repository. These are all valid options and all available to you as a developer. Each would have a different approach. Filesystem would use the ABAP DATASET commands, Database would use normal SQL commands to write into a RAW STRING field, the MIME Repository would use the already mentioned MIME API class.

Former Member
0 Kudos

Hi Thomas,

I want to upload my file to Mime Repository.

I am using the following Code to upload the same.

Content is binded to File Upload UI Element.

data: mime_repository type ref to if_mr_api,

content type xstring.

    • Reading the Values From Context into variable Content type xstring.**

DATA lo_nd_cn_content TYPE REF TO if_wd_context_node.

DATA lo_el_cn_content TYPE REF TO if_wd_context_element.

DATA ls_cn_content TYPE wd_this->element_cn_content.

DATA lv_content TYPE wd_this->element_cn_content-content.

  • navigate from <CONTEXT> to <CN_CONTENT> via lead selection

lo_nd_cn_content = wd_context->get_child_node( name = wd_this->wdctx_cn_content ).

  • @TODO handle non existant child

  • IF lo_nd_cn_content IS INITIAL.

  • ENDIF.

  • get element via lead selection

lo_el_cn_content = lo_nd_cn_content->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_cn_content IS INITIAL.

ENDIF.

  • get single attribute

lo_el_cn_content->get_attribute(

EXPORTING

name = `CONTENT`

IMPORTING

value = content ).

mime_repository = cl_mime_repository_api=>get_api( ).

call method mime_repository->put( exporting i_url = 'SAP/BC/BSP/SAP/WEB_UTILITY' i_content = content ).

Now I am not able to see the uploaded file in the Mime Repository.

Is the Code okay ?

Thanx.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Sure if that is where is you want to store it then that is the correct coding?

Former Member
0 Kudos

Hi Thomas,

Thanx for the answer and quick help from your side.

Answers (1)

Answers (1)

yesrajkumar
Active Participant
0 Kudos

Hi,

Yes, there is an UI element with which you can be able to downlaod the same file.You can upload and download any type of file using the class CL_MIME_REPOSITORY_API.

For example, you have your JPG file in the location ''/SAP/BC/BSP/SAP/myBSPapplication/yourfile.jpg''

You can retrieve the information using the below code,

data:

mime_repository type ref to if_mr_api,

content type xstring,

mime_type type string,

url type string value 'SAP/BC/BSP/SAP/myBSPapplication/yourfile.jpg'.

mime_repository = cl_mime_repository_api=>get_api( ).

call method mime_repository->get

exporting

i_url = url

importing

e_content = content.

e_mime_type = mime_type.

and finally bind the content value to the attribute of your file download UI element.

This is for your additional information, you can use the same class for uploading the documents also.

There is a interface called IF_MR_API~PUT which can help you in doing so.

Thanks,

Rajkumar.S