Unable to download images from published REST API

0
Hi all,   I'm trying to download images from published REST API, but the response is not containing the image. Mendix is sending a HTTP response with multipart/form-data. But I need the binary data of the image file in the reponse. How do we do it.   I have done the same way as said in this document: https://docs.mendix.com/refguide/send-receive-files-rest/   This is the microflow that handles the file download:   These are the headers added: Content-Type: image/png Content-Disposition: attachment Filename: downloaded_image.png Access-Control-Expose-Headers: Filename After adding the Content-Disposition header, the file is getting downloaded. But, its not opening in Photos application, its not in the right format.   I have converted the response to text, and this is the response I'm getting: ------WebKitFormBoundaryZvKhRqqE6hc9lQ46 Content-Disposition: form-data; name="file"; filename="cog-svgrepo-com.png" Content-Type: image/png �PNG  ����� .... some png file data .... ����� ------WebKitFormBoundaryZvKhRqqE6hc9lQ46-- We can convert the response to text and parse the PNG data from it, but there are no good libraries in javascript for it. Also, this does not work for large files.   Why is Mendix sending multipart/form-data response when there is only one file to send? Is there a way we can send direclty the binary data from the published REST API?
asked
2 answers
0

Hi Eessh,

 

Please try with multipart/form-data

 

Hope it helps!

Thanks & Regards,

Manikandan K

answered
0

Hi Eessh,

 

In Header send key as "Content-Disposition" and value as "inline". It will solve your problem.

 

Thanks.

answered