Skip to content

Commit

Permalink
Update download file api route
Browse files Browse the repository at this point in the history
  • Loading branch information
salimi-my committed Feb 4, 2024
1 parent 9ef1fa4 commit 7d7fc89
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions app/api/resume/download-file/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,17 @@ export async function POST(req: Request) {
}

const response = await fetch(resume.pdf);
const pdfData = await response.arrayBuffer(); // Extract PDF data

return new Response(response.body, {
headers: {
...response.headers,
'content-type': 'application/pdf',
'content-disposition': `attachment; filename="salimi-resume.pdf";`
}
});
// Create new Response object with PDF data and headers
const headers = new Headers(response.headers);
headers.set('content-type', 'application/pdf');
headers.set(
'content-disposition',
'attachment; filename="salimi-resume.pdf"'
);

return new Response(pdfData, { headers });
} catch (error) {
let message;

Expand Down

0 comments on commit 7d7fc89

Please sign in to comment.