vika-server / src /utils /download.utils.ts
Viktoria435
Refactor file handling and date parsing in utility functions
c426414
raw
history blame contribute delete
388 Bytes
import { StreamableFile } from '@nestjs/common';
export function buildDownloadFile(
table: string,
id: string,
payload: unknown,
): StreamableFile {
const content = JSON.stringify(payload, null, 2);
const buffer = Buffer.from(content, 'utf-8');
return new StreamableFile(buffer, {
type: 'text/plain',
disposition: `attachment; filename="${table}-${id}.txt"`,
});
}