Unable to open an object url from javascript

I got a Rest API resource returning a binary file as its content. I want to open an url containing this data.

I first thought of using data url, but it seems it is not possible due to limitation in the browser.

So I am able to convert the base 64 data in a blob object and create an object url.
But sadly it appear the utils.openUrl method doesn't allow for blob url, and the window.open(url) method seems to be blocked by retool.

EDIT : I try a workaround by dynamically editing the target of a classic hyperlink (a text component using the markdown for a link) and retool redirect to the app page.

1 Like

Hey @PierrickPC! Thanks for reaching out. :wave:

I don't know if it's the best option, but I'm mostly able to accomplish this using a custom component, as shown below. Note that I'm mocking the result of your API with a simple "File Input" component, which exposes the document data in base64.

I say "mostly" just because Chrome doesn't automatically open data URLs for security reasons, so I currently have to refresh the page in order to see the document. Using a blob URL should bypass this restriction. :+1:

I've included the app JSON, as well: Sandbox.json (10.3 KB).

Hopefully this helps! Let me know if you have any follow-up questions.