cancel
Showing results for 
Search instead for 
Did you mean: 

Open the attachments in SAP UI5?

Former Member
0 Kudos

Hi Ui5 experts,

I have a requirement in UI5 to upload a file.Also I need to open the uploaded file.File may be anything(jpg,xls,doc,xlsx,docx,pdf etc).

I am able to upload the file and save it as binary format in sap and able to show file name on the screen as a link.But I dont know how to open the file when I click on a file.

     Please suggest on how to open the attachments.

Accepted Solutions (0)

Answers (1)

Answers (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi,

you can refer for PDF display and for xls

Regards,

Chandra

Former Member
0 Kudos

Hi,

Thanks for your suggestion.I will try this and get back to you.But I want to understand what you have done in that function module.I think you are uploading content of file to server cache memory.then retrieving the content from server cache using url.

Please correct me if I am wrong and explain in detail

ChandraMahajan
Active Contributor
0 Kudos

Check the recommended and improved approach based on get_stream etc. in the same blog.

In that case, you need not have temporary url stored in cache.

Former Member
0 Kudos

Hi Chandrasekhar,

I tried the approach that you mentioned i.e get_stream.I created the ODATA service  and it is working fine when i tested in gateway.Files are displaying and some files are downloading.Everything is fine.

The problem now is when i tried to use that service and embed the link in Iframe it is displaying the below mentioned content in the iframe

I wrote the below code.Please check and give suggestions

ChandraMahajan
Active Contributor
0 Kudos

may be /ES_FILENAME('HOLIDAY.pdf') might be causing issue. My example code shared in the blog is working perfectly fine. Try again to troubleshoot further.

Former Member
0 Kudos

I gave the same thing in SAP Netweaver Gateway client.It's displaying the PDF as response

Former Member
0 Kudos

Hi Chandrasekhar,

Sorry.I did a mistake in placing the single quotes in the src attribute of html tag.That's why its not fetching the content.Now  I removed the single quotes in src attribute and tested.It's working fine now.

All documents are opening except xlsx documents.When I try to open this document it displays pop up "file is corrupted".

Please suggest on this.

Former Member
0 Kudos

Hi ChandraSekhar,

I solved the xlsx file issue also.There is only one minor problem.When downloading any file it is downloading the file with name $value .

Is there any way to download the file with name of file only?

Former Member
0 Kudos

Corrected

ChandraMahajan
Active Contributor
0 Kudos

Please share the details of the final solution for benefit of the community.

Regards,

Chandra

Former Member
0 Kudos

Hi ChandraSekhar,

I tried the following solution.

When we overwrite the Get_Stream method you need to call one method set_header method with header details that exists in the same class.

data: lwa_head TYPE IHTTPNVP.

lwa_head-name = 'Content-Disposition'.

lwa_head-value = 'attachment; filename="File1.doc"

CALL METHOD me->set_header

   EXPORTING

     is_header = wrk_head

     .