Search code examples
javascripttypescriptsupabase

Supabase select fields from storage file list


The premise is simple. As suggested in the supabase docs I am listing all existing files in my storage bucket using :

    const { data, error } = await supabase
  .storage
  .from('avatars')
  .list('folder', {
    limit: 100,
    offset: 0,
    sortBy: { column: 'name', order: 'asc' },
  })

Is it possible to select only a certain number of fields that this query would return ?

For example, if this were with a database I could specify the fields I want within the .select() clause. (e.g. .select('field_1', 'field_2')). How do I achieve this with supabase storage ? In the scenario where I want only to return the name of the files and their creation date for example.


Solution

  • No, the storage API doesn't support limiting which fields to be retrieved. The piece of information you retrieve with the list() methods are fairly small, so generally shouldn't be too much of an over head to query those extra fields though.