Proxy Community
[b]"How can I use Puppeteer to upload a PDF to Supabase?"[/b] or [b]"Best way to upload a PDF to Supabase using Pu - Printable Version

+- Proxy Community (https://proxycommunity.com/forum)
+-- Forum: Use Case (https://proxycommunity.com/forum/forum-use-case)
+--- Forum: Web Scraping (https://proxycommunity.com/forum/forum-web-scraping)
+--- Thread: [b]"How can I use Puppeteer to upload a PDF to Supabase?"[/b] or [b]"Best way to upload a PDF to Supabase using Pu (/thread-b-how-can-i-use-puppeteer-to-upload-a-pdf-to-supabase-b-%0A%0Aor-%0A%0A-b-best-way-to-upload-a-pdf-to-supabase-using-pu)

Pages: 1 2


[b]"How can I use Puppeteer to upload a PDF to Supabase?"[/b] or [b]"Best way to upload a PDF to Supabase using Pu - CipherGlide77 - 11-01-2025

"Trouble uploading a PDF to Supabase with Puppeteer—any solutions?"

Hey folks!

Been trying to figure out how to use puppeteer upload pdf to supabase, but hitting a wall.

I can generate the PDF just fine, but the upload part keeps failing. Tried using `page.uploadFile()`, but Supabase doesn’t seem to play nice with it.

Anyone got this working? Maybe a workaround or a better approach?

Or am I just missing something obvious? lol

Thanks in advance!

(Also, if you’ve done puppeteer upload pdf to supabase successfully, pls share your code snippet—would be a lifesaver!)


“” - cloakJumpX - 12-02-2025

Hey! Had the same issue last week. Instead of using `page.uploadFile()`, I converted the PDF to a Blob and used Supabase's `storage.from('bucket').upload()` directly.

Here's a quick snippet:
```javascript
const pdfBuffer = await page.pdf();
const { data, error } = await supabase.storage.from('pdfs').upload('file.pdf', pdfBuffer);
```
Works like a charm! Also, check out Supabase's docs on file uploads—super helpful for puppeteer upload pdf to supabase workflows.


“” - darkRushX - 25-02-2025

Yo! Supabase doesn’t handle Puppeteer’s file upload the same way as a browser form. Try this:

1. Save the PDF locally first.
2. Use `fs.readFileSync` to get the buffer.
3. Upload via Supabase JS client.

Bonus: If you’re dealing with large files, chunking might help. Let me know if you need the chunking code!


“” - stealthNodeX - 09-03-2025

Struggled with puppeteer upload pdf to supabase too. Found that `page.uploadFile()` is flaky with Supabase’s API.

Workaround: Use `page.pdf()` to get the buffer, then POST it via fetch or the Supabase SDK.

Also, make sure your bucket permissions are set to public/private correctly. That tripped me up for hours lol.


“” - secureTorX - 19-03-2025

If you’re generating the PDF with puppeteer, skip the file step entirely! Just grab the buffer from `page.pdf()` and push it straight to Supabase storage.

Code:
```javascript
const pdf = await page.pdf({ format: 'A4' });
await supabase.storage.from('bucket').upload('output.pdf', pdf);
```
No temp files, no fuss. Works every time for me.


“” - CipherGlide77 - 20-03-2025

Wow, thanks everyone! Didn’t realize I could skip the file step entirely and just use the buffer. Tried the `page.pdf()` + direct upload approach, and it worked!

One follow-up: What’s the best way to handle errors if the upload fails? Should I retry or just log it?

Also, big thanks for the RLS reminder—totally forgot to check that. You all saved me hours of headache!


“” - darkDashX77 - 21-03-2025

Hey! Had this exact puppeteer upload pdf to supabase problem. Turns out, Supabase expects raw bytes, not a file path.

Try this:
- Generate PDF with `page.pdf()`.
- Convert to Blob or use the buffer directly.
- Upload with `supabase.storage.upload()`.

Also, double-check your RLS policies if it’s still failing.


“” - proxyHawk_88 - 23-03-2025

Supabase + Puppeteer can be tricky for file uploads. Instead of `uploadFile()`, I used `page.pdf()` to get the buffer and then:

```javascript
const { error } = await supabase
.storage
.from('pdfs')
.upload('doc.pdf', await page.pdf());
```
If you’re still stuck, maybe try logging the error object? Might give you a clue.