fix(ex/retirement): document
This commit is contained in:
parent
05c38b8d8e
commit
11586a8fb2
1 changed files with 12 additions and 2 deletions
|
|
@ -100,7 +100,7 @@ export class ExRetirementController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("/document/{documentId}")
|
@Get("/document/{documentId}")
|
||||||
async getDocument(@Path("documentId") officerDocumentID: string) {
|
async getDocument(@Path("documentId") officerDocumentID: string, @Request() req: any) {
|
||||||
let retryCount = 0;
|
let retryCount = 0;
|
||||||
const maxRetries = 2;
|
const maxRetries = 2;
|
||||||
while (retryCount < maxRetries) {
|
while (retryCount < maxRetries) {
|
||||||
|
|
@ -118,8 +118,18 @@ export class ExRetirementController extends Controller {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
|
responseType: "arraybuffer",
|
||||||
});
|
});
|
||||||
return res.data;
|
|
||||||
|
if (!req.res.headersSent && !req.res.destroyed) {
|
||||||
|
// Set response headers
|
||||||
|
req.res.setHeader("Content-Type", "application/pdf");
|
||||||
|
req.res.setHeader("Content-Disposition", `inline; filename="${officerDocumentID}.pdf"`);
|
||||||
|
req.res.setHeader("Content-Length", res.data.byteLength.toString());
|
||||||
|
|
||||||
|
req.res.end(Buffer.from(res.data));
|
||||||
|
return;
|
||||||
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error.response?.status === 500 && retryCount < maxRetries - 1) {
|
if (error.response?.status === 500 && retryCount < maxRetries - 1) {
|
||||||
TokenCache.delete(`${clientId}:${clientSecret}`);
|
TokenCache.delete(`${clientId}:${clientSecret}`);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue