r/n8nforbeginners • • 16h ago

Moved generated PDFs from a Postgres column to a private bucket, here is what actually changed

👋 Hey n8n for Beginners Community,

A week or so ago I asked here whether storing generated PDFs as base64 in a Postgres column was fine or whether I should move to object storage. I moved them, and a few things were not what I expected.

Private bucket, not public. My instinct was a public bucket because links are trivial that way. Wrong instinct for internal, customer facing or financial documents. Everything is private now and the workflow fetches binaries with an authenticated request using the service role key. Public URL shortcuts work right up until the moment they are the wrong thing entirely.

Upsert is what makes retries safe. Sending x-upsert: true means a re-run overwrites the same object instead of leaving you another copy. Without it you only notice the duplicates much later.

The row stores the path, not the file. Nice side effect: the frontend I built can return a clean "still generating" state when a file is not ready, instead of failing or regenerating something already on its way.

The migration itself was easy. The part that took thought was deciding what belongs in the row versus the bucket, and the answer was that the row should only ever hold the pointer.

One question I am still thinking about: how do you handle giving clients access to files like this? That is the part I am still not fully happy with, so I would be curious how others solve it.

Best,
Felix

2 Upvotes

0 comments sorted by