Skip to Content
0

SAP UI5 Bad content of file after downloading from Gateway

Jan 29 at 09:17 AM

92

avatar image
Former Member

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Krishna Kishor Kammaje
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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Krishna,
I don't think so, because Postman application can successfully open file. I am sending file in hexadecimal form like XSTRING type and when I try to convert hexadecimal value of file (stored in database) to string the source of file was the same as orginal source of file. It looks that Javascript has conversion trouble.

0

The Postmasn application might be doing additional processing of removing spaces at the end. Did you check in the WIndows GUI?

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

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


Share
10 |10000 characters needed characters left characters exceeded
Ankit Maskara
Jan 30 at 05:49 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 03 at 08:51 AM
0

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!");
			}
Share
10 |10000 characters needed characters left characters exceeded