Store files safely: uploads, invoices and photos: a Claude + Lovable + Supabase stack

The struggle: Your app lets users upload files and you are unsure who can open them.

What you end up with: File uploads with private storage where each user can open only their own files, tested with two accounts.

Decide which files are public and which are private, ask Lovable for a private bucket with owner rules, check the policies in Supabase and try to open another user's file before launch.

Tools: Claude, Lovable, Supabase. Level: Free to start. Time: 2 hours.

Use it if

  • Your app lets users upload files
  • You are unsure who can open an uploaded file
  • The files are invoices, IDs or photos

Skip it if

  • You store identity documents or health files: a security professional must design this
  • You only show your own public images

The method

  1. Sort files by who may see them (Claude: Chat)

    List the kinds of files and who should open each. Ask for a table of public and private files, size and type limits and a deletion rule.

    Prompt to copy:

    Create a storage plan for my app. File types: [list]. For each say: public or private, who may upload, who may open, allowed formats, size limit, how long we keep it and how it is deleted. Flag anything that looks sensitive. Ask me before assuming. Keep it as a table.

    You get: A file access table.

    Tip: Treat any invoice, ID or photo of people as private by default.

  2. Plan private storage (Lovable: Plan mode)

    In Plan mode paste the table and ask for upload with private buckets, files saved under each user's folder, format and size checks, and short-lived signed links to open files. On Supabase's free tier individual files are limited to 50 MB. Approve the plan.

    Prompt to copy:

    Plan file uploads from this table: [paste]. Use private storage buckets, store each file under the logged-in user's own folder, check format and size before uploading, open files only through short-lived signed links, and show only the user's own files. Do not make any bucket public unless the table says so.

    You get: A plan with private storage.

    Tip: Ask Lovable to list each policy it adds.

  3. Read the policies yourself (Supabase: Storage)

    In the Supabase dashboard check that the bucket is private and that policies on stored objects allow a user to read and add only their own files. Public buckets are readable by anyone with the link.

    You get: Policies you have read.

    Tip: Overwriting a file needs more than insert, so check update and select too.

  4. Write the two account test (Claude: Chat)

    Ask for a test list for two accounts, including opening another user's file link and a logged-out visitor opening a file link.

    Prompt to copy:

    Write a test list for file uploads with accounts A and B and a logged out visitor. Include A uploads then B tries the file link, the visitor opens a copied link, a file too big, a wrong format and deleting a file. Format: Steps, Expected, Result.

    You get: A test list for access.

    Tip: A copied link is the quickest way to find an open file.

  5. Run the test with fake files (Lovable: Preview)

    Upload harmless files, such as a blank invoice, with fake accounts and run every test. Fix one failure at a time and run it all again.

    You get: A passed test.

    Tip: Never test with real invoices or customer photos.

Where this goes wrong

  • Access rules must be tested by a person before real files go in.
  • Check privacy, retention and deletion rules for personal files with a qualified person.
  • A secret service key skips storage rules, so keep it out of browser code.
  • Keep only the personal data the job needs, and delete files when the retention rule says so.

Swap a tool

  • Bolt.new instead of Lovable: Bolt also has a built-in database and hosting.

Sources

More like this

Updated . Written with AI help and checked by an independent review step, as described in our editorial standards.