jsreport pdf save into postgresql bytea field
-
I want to save pdf into postgresql bytea field
My code is:
var data = {
template:{"shortid":"BkeiI9trWP"},
data: {"rows": genStatsJSON[0].jsonlistb },
options: { 'Content-Disposition': 'Attachment; filename=badges.pdf' }
}
var options = {
uri: 'http://localhost:3000/reporting/api/report',
method: "POST",
json: data
}const file = fs.createWriteStream('databaseReport.pdf'); const response = await request(options).pipe(file);
const saveJob = await getManager().query(
INSERT INTO jobs_report (job_id, report_name, report_bytes) VALUES('d28d47ec-f5ee-41b9-a9a3-61796891e9e6','databaseReport.pdf', '${response}')
);How can I save in node.js?