I´ll describe my end goal right away: I want to be able to take screenshots of my website with puppeteer and upload them straight to google cloud storage (with cloud functions for example).
However, I've been running into an issue with actually uploading the file if I do not give a path to locally store it. This is the code I have:
(async () => {
const browser = await puppeteer.launch({headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox']});
const page = await browser.newPage();
await page.goto('https://google.com');
const filename = await page.screenshot();
await storage.bucket(bucketName).upload(filename, {
gzip: true,
})
console.log(`${filename} uploaded to ${bucketName}.`);
await browser.close();
})();
I have tried a variety of things like encoding the image differently and converting it from a buffer to a string but I keep running into the same two errors, either:
- The "path" argument must be of type string. Received an instance of Buffer, or
- The argument 'path' must be a string or Uint8Array without null bytes.
I appreciate all the help I can get :D Kind regards