Return report from MPS (Matlab production server)

I am using MPS for computation and reactJS as front end. After computation, I generate report using mlreportgen in docx. In local installation it is saved in a director.
When deploying on MPS, how can I return docx report back to reactJS front end? I am ok with html or pdf report too.
Thanks,

답변 (2개)

Dheeraj
Dheeraj 2024년 1월 8일

0 개 추천

Hi,
I understand that you want to know how to retrieve docx report back to reactJS front end from your MPS.
When deploying a MATLAB Production Server (MPS) application with a ReactJS front end, you typically communicate between the front end and the server through HTTP requests. In order to do this, you could expose an API that communicates with the front end.
  1. Generate the report through the MPS Application and save the report in an accessible location.
  2. In your MPS application, expose an API endpoint that allows the ReactJS front end to request the generated report. You can use MATLAB functions like webwrite or urlread to make HTTP requests.
  3. In your ReactJS application, make an HTTP request to the MPS API endpoint that generates and sends the report. You can use libraries like axios for making HTTP requests.
You could use the below MATLAB documentation to know more about “webwrite” and “urlread.
Hope this helps!
Nicole Bonfatti
Nicole Bonfatti 2026년 5월 6일 19:27

0 개 추천

There are a couple ways to do this:
  • Enable static file hosting in your Production Server config and write the docx to the static_files folder in your mps instance folder, then GET it from <servername>:<port>/~files/<filename>.docx
Alternately,
  • Return the docx as a string in the server response by reading the generated file and base64-encoding it with matlab.net.base64encode(). Then on the client side, base64-decode it to write to a file.
The first option will require you to periodically clear out the files from the static_files folder, but the second option means you can delete it from the server as soon as its base64 encoded.

카테고리

질문:

2022년 3월 14일

답변:

2026년 5월 6일 19:27

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by