storage icon indicating copy to clipboard operation
storage copied to clipboard

Include user metadata in the first insert for objects

Open anmolsood21 opened this issue 11 months ago • 4 comments

In order to be able to use passed in user metadata for INSERT RLS policies, the user metadata should be included in the first insert request. Currently, the first insert request doesn't have any user metadata set.

See https://discord.com/channels/839993398554656828/1338777324845404262/1338777324845404262 for more context

anmolsood21 avatar Feb 11 '25 19:02 anmolsood21

This has come up before with at least 1 or 2 users.

GaryAustin1 avatar Feb 11 '25 19:02 GaryAustin1

Cant see whats behind the discord link but think I might be running into this issue as well.

        const { error } = await supabase.storage
          .from(uploadUrlData.bucket)
          .uploadToSignedUrl(uploadUrlData.path, uploadUrlData.token, file, {
            upsert: true,
            metadata: uploadUrlData.metadata
          });

Results in the file being uploaded, and an object. However, none of the metadata is actually set in the table. Not in the metadata or user_metadata column

RickVM avatar Feb 27 '25 13:02 RickVM

+1 This sounds like a great function that opens up a lot of possibilities. If the metadata were inserted into the table when the first insert occurred, it could be used in RLS, triggers, etc.

supron54321 avatar Apr 17 '25 20:04 supron54321

& this feature has been supported by S3, Azure, GCS and among all major storage providers

alvis avatar Nov 08 '25 10:11 alvis