Skip to content

Commit

Permalink
add timestamp to file name
Browse files Browse the repository at this point in the history
  • Loading branch information
freddieptf committed Feb 16, 2024
1 parent d796bd4 commit d463686
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/public/app/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<span class="material-symbols-outlined">group_add</span> Upload
</a>

<a class="navbar-item" href="/files/credentials" download="{{ session.authInfo.domain }}.users.zip">
<a class="navbar-item" href="/files/credentials">
<span class="material-symbols-outlined">save_as</span> Save Credentials
</a>

Expand Down
5 changes: 2 additions & 3 deletions src/routes/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContactType, String[][]>();
const places = sessionCache.getPlaces();
Expand All @@ -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);
Expand All @@ -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();
});
}

0 comments on commit d463686

Please sign in to comment.