0

Dear SAPUI5 developers,

How can I download a blob data as file in SAPUI5?

I have a blob object:

"data:image/jpeg;base64,MjU1MjE2MjU1MjI0MDE2NzQ3MDc....."

I can not use the normal method that we usually use in JavaScript.

I mean window.URL.createObjectURL(blob); does not make a correct url for the blob data.

Can you tell me how can I do that?

Thanks in advance.

MJBZA
  • 4,796
  • 8
  • 48
  • 97

2 Answers2

1

I had the same problem. Mostly you used sap.m.Link for creating the download link. I know if you create a anchor (a tag in HTML) and want to inject it in the body element you will receive the following warning:

ESLint(sap-no-dom-insertion): Direct DOM insertion is forbidden!

But ignore the warning and create a a tag and inject it in the body.

There is a good solution here:

JavaScript blob filename without link

Community
  • 1
  • 1
0

You can create download link with object onfly and fire click event or user can click. Example: Create a file in memory for user to download, not through server

Community
  • 1
  • 1
mkysoft
  • 5,392
  • 1
  • 21
  • 30
  • This method does not work in SAPUI5 because it is MVC model and has its own routing. then creating a URL does not work in SAPUI5 application. – MJBZA Dec 29 '16 at 08:59