The following code runs flawlessly when tested locally, but returns the following error when run during render cron job. This project is using puppeteer and I assumed there would be some limitations to using fs when deployed to render such as all files being deleted after instance spins down ect. However, I did not expect this. I only need the file to be stored for a couple seconds so I can then
use puppeteer to upload the file. What is the best way of doing this? Some sort of temp storage? I only need the file to be stored for a couple seconds so it can be uploaded.
Also, sorry if formatted this post wrong this is my first time posting! Please let me know if you need more code, context ect.
Thanks!
Error: EACCES: permission denied, open ‘image.jpg’
Code:
const imageUrl = ‘https://plus.unsplash.com/premium_photo-1669048776605-28ea2e52ae66?q=80&w=2670&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D’;
const viewSource = await page.goto(imageUrl);
const buffer = await viewSource.buffer();
fs.writeFileSync('image.jpg', buffer);
await page.goto("https://medium.com/new-story");
await page.waitForSelector('h3', { timeout: 60000 });
await page.waitForSelector('[data-testid="editorAddButton"]');
// Click the button
await page.click('[data-testid="editorAddButton"]');
await delay("2000");
const [fileChooser] = await Promise.all([
page.waitForFileChooser(),
page.click('button[aria-label="Add an image"]')
]);
await fileChooser.accept(['image.jpg']);