1
I have a small problem in downloading PDF files
I have a API that returns a array bytes with the type: "application/pdf"
, if I call straight in my browser route.
Ex: localhost/api/download/pdf/{id}
The PDF download is performed without any problems
But in the React, I am using the axios
to carry out the requisition get
my API and am using the React-file-download to download the answer DATE, but the mounted PDF is coming blank
I download to other formats, such as CSV and TXT, in the same way, using the react-file-download
and they are accomplished without the slightest trouble
but with PDF I’m having this problem
i saved the date that is coming in the answer from Xios that is the result: https://pastebin.com/FkL8snWr
I am currently "working around" the problem using window.location.href to call my API address. Ex: window.location.href = localhost/api/download/pdf/{id}
the download is performing normally
Has anyone been through this? how vcs download PDF, or other files?
Downloading a file works only in the case of a 'GET' request. You can simply create an API that accepts a 'GET' request. And on the client side, in some action You can call window.open ('server full url with api path'). And start downloading your file.
– Lollipop