Skip to Content
avatar image
Former Member

SAP UI5 Bad content of file after downloading from Gateway

I have the UI5 application with upload and download file functionality. The uploading works fine but when I download file - f.e. jpeg type, Windows Photo Viewer give me a message "Windows Photo Viewer can't open this picture because the file appears to be damaged, corrupted, or is too large". The file is uploaded by gateway to database table in XSTRING format. I tested uploading and downloading functionality by Postman and everything works fine.
Backend site:
ui5script.jpg

Frontend site:
ui5script.jpg

Result of file source comparing before uploading and after downloading:
capture.jpg
As you can see some special characters were not be decoded.

Can anybody help me with this issue ?
Regards,
Juraj

ui5script.jpg (55.5 kB)
ui5script.jpg (55.5 kB)
capture.jpg (872.3 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Jan 30 at 04:12 AM
    -1

    Hi Juraj,

    Problem is while uploading, not downloading. You can confirm this by looking at the uploaded attachemnt in WinGUI.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 29 at 09:20 AM

    Sorry, my backend functionality looks like this:
    get-stream-func.jpg

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 30 at 05:49 PM

    Code looks fine. As mentioned by Krishna, such issues generally comes up when the file is not correctly uploaded on the DMS. For this purpose we should always keep a file size property alongwith other file attributes. While uploading we store the file size as well so that during download the media content stored in DMS is converted till the stored size only. It's commonly observed that sometimes the DMS stores extra whitespaces at the end - some sort of padding. To mitigate this issue storing file size is recommended.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 03 at 08:51 AM

    Thank you guys. The issue is solved. Instead of creating Blob object and link on its,I just open new tab in browser with URL to GET_STREAM method.

                            try {
    				sap.m.MessageToast.show("File will be downloaded in several seconds");
    				window.open(url, "_blank");
    			} catch (err) {
    				sap.m.MessageToast.show("Error during file downloading!");
    			}
    
    Add comment
    10|10000 characters needed characters exceeded