So I want to download a csv with puppeteer, which runs on a firebase cloud function.
Since I don't want it to be persistent, I want to store it in the cloud functions tmp folder.
After some research I found that the best way to access this folders path is by calling os.tmpdir().
So this is my current function:
const downloadPath = `${os.tmpdir()}` + '/storageFolder';
await page._client.send('Page.setDownloadBehavior', {
behavior: 'allow',
downloadPath: downloadPath,
});
await page.waitForTimeout(500);
await page.$eval('mybutton', (mybutton) => mybutton.click());
await page.waitForTimeout(1000);
But when I check this path again, there is no file in ${os.tmpdir()}` + '/storageFolder'
At least when I do this:
fs.readdirSync(downloadPath).forEach(file => {
console.log("Filename", file);
});
Nothing gets printed to the console.
I know there are multiple questions about this but every accepted answer is to download the file from the url but in my case there is no way to get the url.
So why is there no file in the specified folder? What am I doing wrong?