Get Free Trial

How can I save the report as a Multipart file.

Answered
gssspillai asked on August 30, 2021

I’m using angular and spring boot. And I want to save the report in server. So I tried MultipartFile in the spring boot controller to store request params and file is not saving. So is there any better way to do it? or is there any default format for RequestParms?
 
 
 
Here is my code
.ts file
 
function reportSaveHandler() {
            pivot.save({
                filename: ‘myreport.json’,
                destination: ‘server’,
                url: ‘http://localhost:8082/reports/uploadFile’,
                requestHeaders:{
                    ‘Authorization’:’Bearer ‘+token,
                }
            });
        }
 
.java File (controller)
 
public class ReportsController {
@RequestMapping(method = RequestMethod.POST,value = “/uploadFile”)
public void uploadReports(MultipartFile file) {
System.out.println(file.toString());
}
}
 
 
I’m getting nullpointerException while printing. 
 
 
 

1 answer

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster August 30, 2021

Hello,
 
Thank you for posting on our forum.
 
Please note that when saving files, Flexmonster is only responsible for preparing the report and sending it to the specified URL in JSON format. Further handling depends on the server-side stack and cannot be affected from our side.
 
We recommend checking out the following StackOverflow thread describing a similar problem: java – Spring Boot MultipartFile always has value of null.
 
Alternatively, you can retrieve the inline JSON object representing the report using the getReport method. Next, it can be sent to your server-side manually in the desired way.
 
We hope it helps.
 
Kind regards,
Illia

Please login or Register to Submit Answer