ReadFileAsBytes into Perspective PDF Viewer

Hi,

Is it possible to use fonction system.file.readFileAsBytes() and put the result into a Perspective PDF Viewer ?

With the WebDev module. (If you mean a file in the machine running the browser, no, not at all.)

Yes I made an API Post request to send me bytes of a PDF file on my server.

But How can I use my received bytes in my PDF Viewer ?

Make it a GET request so you can put the URL in the viewer.

It works.
How can I use basic Auth securely ?

Is it possible to download the showed PDF in the component ?

Pass the bytes provided by the get request to a call to system.perspective.download

I'm passing the GET URL directly into the PDF Viewer's source prop. How can I access the raw bytes inside the component? I know I could make a separate request to fetch them and download the pdf, but I'd prefer to handle it in a single request.

You cannot. You need to make a separate button that either generates the bytes independently for system.perspective.download(), or links to the same URL for the browser to handle the download itself.

If the report is complex, consider caching the result for a short time, so the separate requests don't multiply the workload.