supabase / storage

S3 compatible object storage service that stores metadata in Postgres
https://supabase.com/docs/guides/storage
Apache License 2.0
811 stars 115 forks source link

Add `file_metadata` field to objects schema #439

Closed bombillazo closed 4 months ago

bombillazo commented 9 months ago

Feature Request

Currently, the objects schema in the Storage API schema is a light abstraction over the S3 storage. There is a metadata column in the objects table, but it corresponds to the metadata of the S3 file and cannot be used by the user. The API does not expose any way to add related metadata to a file to the objects directly. This metadata would ideally be in JSON format to contain user-determined data. Currently, the user needs to get around this limitation by either:

The storage API should natively support metadata, and the API / JS clients should be updated to enable this powerful and common feature for file storage management. My proposal is to add a new column called file_metadata to differentiate it to the current metadata field.

fenos commented 8 months ago

@bombillazo I generally agree that allowing Storing arbritary metadata could be a nice feature to have in Storage. Will add this on the roadmap! ๐ŸŽ‰

logemann commented 7 months ago

strong agree on adding custom metadata per storge object. Having to maintain a mirror table just for additional data is a pain, especially the lack of usable triggers to keep both sides in sync.

dmbr0 commented 7 months ago

+2 for this. I would definitely like this. would like to tag files that are being uploaded.

Razikus commented 7 months ago

+1

zhanziyang commented 7 months ago

+1 for this

joe-ashwell commented 7 months ago

Also +1

oleva commented 7 months ago

Would make multi tenant systems a lot easier to manage. Ie. tenants quota. | +1

lecramr commented 7 months ago

+1

danvoyce commented 6 months ago

+1000000000

I'm currently having to add metadata into my file names, so would love to clean up this mess!

momongah commented 6 months ago

+1 for this. I'm currently working with AI generated images and need to store the prediction parameters that generated each image. Otherwise I gotta use AWS S3 cuz I know they have metadata feature.

KindArt commented 6 months ago

+1

ykoitzsch commented 6 months ago

+1 looking forward to this

vatanak10 commented 6 months ago

+1

loringabriel commented 6 months ago

+1

PremchandGat commented 5 months ago

+1 looking for same

normanyu commented 5 months ago

This would improve my workflow with supabase as well. Right now, I need to keep a separate table and keep it in sync every time i upload, move or delete objects.

Gbillington1 commented 5 months ago

+1

I switched from self hosting to supabase, closed down my own s3 bucket to use supabase storage, and now I can't store metadata on the objects... Please please please add this functionality!

Protonosgit commented 5 months ago

+1 seems very helpful!!

patra0o commented 5 months ago

+1

fahad-frontend commented 5 months ago

+999 would really help out majorly in making supabase storage my go to for all apps. Currently having to use alternatives despite using supabase db and auth

tusamni commented 4 months ago

Great request.

bombillazo commented 4 months ago

@fenos on this topic, since we're not sure when we might get this, is it wise to add a custom trigger to the storage schema so that when a DELETE event happens on the objects table, we can automatically delete it in our metadata table?

These are the types of things having a dedicated file_metadata field would prevent so we wouldn't have to sync data and resources across tables.

Aadilhassan commented 4 months ago

+1

Toshiro00 commented 4 months ago

+1 it could prevent extra table for metadata

Aadilhassan commented 4 months ago

@fenos Thank you for your work on this project. Could you please provide an example implementation for this feature? It would be really helpful for understanding how to integrate it properly.

fenos commented 4 months ago

Hi @Aadilhassan thanks for your kind words. I still need to implement this feature in storage-js (the client) once that's done I'll create the official docs.

Will let you know when these are done ๐Ÿ‘ very excited to have this feature!

tusamni commented 4 months ago

Thanks for the update @fenos. I'm currently building my photography portfolio. I'm assuming I'd be able to store photo JSON data alongside each image uploaded to storage, correct?

If so, I'm a customer now!

bombillazo commented 4 months ago

Hey @fenos , I'm excited about this feature!

I saw the changes and don't see any way to pass the new user_metadata field to the POST/PUT Storage API endpoints.

fenos commented 4 months ago

@tusamni Yes correct! ๐ŸŽ‰

@bombillazo The client-side changes are in the making

y4my4my4m commented 4 months ago

@fenos was just looking for this and couldn't be happier to see this is currently being worked on.

Thank you! Patiently waiting.

felipenmoura commented 2 months ago

Hey there. So...any update or documentation on this? I saw a merged PR but I couldn't find a way to have it working. Should I go ahead and create a table and all that it implies to deal with extra data for media?

Thanks.

logemann commented 2 months ago

Yeah... any news on it would be nice. Perhaps we should open a new one for this since this case is closed, which is also kind of weird to close a case while there is no way using this feature.... @fenos

y4my4my4m commented 2 months ago

@felipenmoura @logemann https://github.com/supabase/storage-js/pull/207 this needs to be merged before you can use it with the client

felipenmoura commented 2 months ago

@felipenmoura @logemann supabase/storage-js#207 this needs to be merged before you can use it with the client

Awesome, sounds great

Thanks.

tHyenigmatiC commented 2 months ago

+1 Waiting for this.

valentindoering commented 2 months ago

+1 waiting for this

craig-at-metashield-io commented 1 month ago

++ excited for this!

anthonylan commented 1 month ago

+1 waiting for this feature

naimRahman08 commented 1 month ago

+1 waiting for this

tillka commented 2 weeks ago

I am confused. I followed the merge-chain and this feature seems to be fully merged and released. I updated my @supabase/supabase-js package so that it includes @supabase/storage-js:2.7.0. However the type FileOptions do not include a metadata field

export interface FileOptions {
  /**
   * The number of seconds the asset is cached in the browser and in the Supabase CDN. This is set in the `Cache-Control: max-age=<seconds>` header. Defaults to 3600 seconds.
   */
  cacheControl?: string
  /**
   * the `Content-Type` header value. Should be specified if using a `fileBody` that is neither `Blob` nor `File` nor `FormData`, otherwise will default to `text/plain;charset=UTF-8`.
   */
  contentType?: string
  /**
   * When upsert is set to true, the file is overwritten if it exists. When set to false, an error is thrown if the object already exists. Defaults to false.
   */
  upsert?: boolean
  /**
   * The duplex option is a string parameter that enables or disables duplex streaming, allowing for both reading and writing data in the same stream. It can be passed as an option to the fetch() method.
   */
  duplex?: string
}

Similarly, neither .info() nor .exists() exist on supabase.storage.fom(bucket).

Could you update the documentation or bring me on the right track @fenos ?

fenos commented 2 weeks ago

@tillka you should be updating storage-js to @supabase/storage-js:2.7.1

pi43r commented 1 week ago

Do I get this right that metadata does not yet work with supabase.storage? I have to use the dedicated StorageClient?

I would like to get my stored metadata through supabase.storage.list() rather than iterating over it and calling storageClient.info() for each file.

traianturcu commented 4 days ago

It would be really nice if supabase.storage.list() would return user_metadata along with the other file properties! We use the custom metadata field to store the original file names..

In the meantime the solution I'm using is to send a request to the backend where I query the storage.objects table directly:

    const { data, error } = await supabase
      .schema("storage")
      .from("objects")
      .select("*")
      .eq("bucket_id", bucketId)
      .eq("owner_id", userId)
      .ilike("user_metadata->>originalFileName", `%${search}%`);
jdhenry08 commented 1 day ago

It would be really nice if supabase.storage.list() would return user_metadata along with the other file properties! We use the custom metadata field to store the original file names..

In the meantime the solution I'm using is to send a request to the backend where I query the storage.objects table directly:

    const { data, error } = await supabase
      .schema("storage")
      .from("objects")
      .select("*")
      .eq("bucket_id", bucketId)
      .eq("owner_id", userId)
      .ilike("user_metadata->>originalFileName", `%${search}%`);

How are you doing this? I keep getting an error:

{
  code: 'PGRST106',
  details: null,
  hint: null,
  message: 'The schema must be one of the following: pg_pgrst_no_exposed_schemas'
}
traianturcu commented 1 day ago

You need to expose the storage schema from Settings > API > Exposed Schemas