mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-03-07 00:17:02 +01:00
28 lines
723 B
TypeScript
28 lines
723 B
TypeScript
|
|
||
|
import express, { Request, Response } from 'express';
|
||
|
|
||
|
export function respondWithBinaryPdf(res: Response, buffer: Uint8Array, filename: string) {
|
||
|
res.writeHead(200, {
|
||
|
'Content-Type': "application/pdf",
|
||
|
'Content-disposition': 'attachment;filename=' + filename,
|
||
|
'Content-Length': buffer.length
|
||
|
});
|
||
|
res.end(buffer)
|
||
|
}
|
||
|
|
||
|
export function response_mustHaveExactlyOneFile(res: Response): void {
|
||
|
res.status(400).send([
|
||
|
{
|
||
|
"message": "file is required",
|
||
|
"path": [
|
||
|
"pdfFile"
|
||
|
],
|
||
|
"type": "file",
|
||
|
"context": {
|
||
|
"label": "pdfFile",
|
||
|
"key": "pdfFile"
|
||
|
}
|
||
|
}
|
||
|
]);
|
||
|
}
|