Help with Binary File Download

I have a GET request to a 3rd Party API which following authentication via a Token, serves a file for download within my Node.js page.

The response is as below

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 1374268
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Expires: -1
Server: Microsoft-IIS/10.0
Content-Disposition: attachment; filename=Service.docx
X-AspNet-Version: 4.0.30319
Request-Context: appId=cid-v1:1b8206f4-419d-4fa8-90d9-a200e9b5aa03
Access-Control-Expose-Headers: Request-Context
X-Powered-By: ASP.NET
Date: Sun, 08 Aug 2021 17:06:23 GMT
Connection: close

and then all the binary data in the data {} …

I am struggling to find a way to allow the file to be downloaded within my page design.
The Server Action runs fine, but how do I save the generated data into a file and download?

Thanks in advance.

Any help would be appreciated with this.

I don’t believe the native api action can handle that yet. This might help

Thanks for the link @mebeingken
I’ve just installed the custom extension and see how it handles file uploads.
But I only need to download binary files that are served through the API and cannot get my head around it.

If I open my Server Action in the browser I get

The link Ken has shared is for uploading a binary file. You need to create a custom module to handle the binary file and save it on server. Then, use Wappler File Download to download the file on client side.

Wappler just works with JSON API request & responses. Anything else needs custom handling.

Thanks @sid
Appreciate you taking time to reply.
If anyone is able to help point me in the right direction, that would be great.

I wrote a download module a while back. If you pass to it a url that returns a file, it will write the file to the local server.

Maybe you can figure out how to add the functionality you need for your api call.

1 Like