JavaScript: list

Lists all the files and folders within a path of the bucket.

Important: For folder entries, fields like id, updated_at, created_at, last_accessed_at, and metadata will be null. Only files have these fields populated. Additionally, deprecated fields like bucket_id, owner, and buckets are NOT returned by this method.

Parameters

Examples

List files in a bucket

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

// Handle files vs folders
data?.forEach(item => {
  if (item.id !== null) {
    // It's a file
    console.log('File:', item.name, 'Size:', item.metadata?.size)
  } else {
    // It's a folder
    console.log('Folder:', item.name)
  }
})

Search files in a bucket

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