From d463686f63b1efe9d6e772aaa5081621173a2313 Mon Sep 17 00:00:00 2001 From: freddieptf Date: Fri, 16 Feb 2024 20:47:52 +0300 Subject: [PATCH] add timestamp to file name --- src/public/app/nav.html | 2 +- src/routes/files.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/public/app/nav.html b/src/public/app/nav.html index a2598b5d..b66acffc 100644 --- a/src/public/app/nav.html +++ b/src/public/app/nav.html @@ -74,7 +74,7 @@ group_add Upload - + save_as Save Credentials diff --git a/src/routes/files.ts b/src/routes/files.ts index 8f9d295a..f906caf7 100644 --- a/src/routes/files.ts +++ b/src/routes/files.ts @@ -20,7 +20,7 @@ export default async function files(fastify: FastifyInstance) { return stringify([columns]); }); - fastify.get('/files/credentials', async (req) => { + fastify.get('/files/credentials', async (req, reply) => { const sessionCache: SessionCache = req.sessionCache; const results = new Map(); const places = sessionCache.getPlaces(); @@ -37,7 +37,6 @@ export default async function files(fastify: FastifyInstance) { result.push(record); results.set(place.type, result); }); - const zip = new JSZip(); results.forEach((places, contactType) => { const parent = Config.getParentProperty(contactType); @@ -56,7 +55,7 @@ export default async function files(fastify: FastifyInstance) { }) ); }); - + reply.header('Content-Disposition', `attachment; filename="${Date.now()}_${req.chtSession.authInfo.friendly}_users.zip"`) return zip.generateNodeStream(); }); }