Transferring blobs from backend to frontend

Hi,

I’m making a cs.curl request in an action in main.js that returns a png image as a blob, is it possible to return this to the frontend and then process the blob?

Thanks,
Ewan

Hi,

Have a look at the main.js class → action_xxxxx method in the right hand side help section
Click on the view examples button, there you can find an example on how to transfer data from the backend (main.js) to your frontend as an action.

You will need to base64 encode the raw image content before sending it as well as decode it on the frontend.

Hi Gediminas,

I’ve already got an action setup to return data from the backend, it looks like the issue is coming from the response being binary data.

Do I have to convert this raw image to base64 to pass it over to the front end, is it completely impossible to get binary data in a blob to the frontend? Ideally I’d like to avoid encoding it as its less efficient.

Thanks,
Ewan

As far as I know I don’t think there is a way to control what content type you are returning in the action response, so I think your only options are to either base64 encode it or perhaps if you need to keep the image, you could store that in an object and just return it’s url to the frontend.

1 Like