I've tried the code below, but Google Cloud Function's limit for a response is only 10M, but I want to return larger files:
const csv = json2csv(onlyDataTransactions);
response.setHeader(
"Content-disposition",
"attachment; filename=transactions.csv"
);
response.set("Content-Type", "text/csv");
response.status(200).send(csv);
Updated: Thanks to @Andrew I have this first update on code, I force the compression because compression middleware on firebase cloud functions depends even on user-agent header, I still working o the other suggestions to find the best result, thanks to all.
if (request.headers['content-type'] === 'text/csv') {
const onlyDataTransactions = transactions.map(transaction => transaction.toCsvRecord());
const csv = parse(onlyDataTransactions);
response.setHeader(
"Content-disposition",
"attachment; filename=transactions.csv"
);
response.set("Content-Type", "text/csv");
response.set('Content-Encoding', 'gzip');
const content = await gzip(JSON.stringify(csv));
response.status(200).send(content);
}