Back

Storage - How to query <storage>.listFiles()

  • 0
  • Web
Isak
24 May, 2024, 15:38

I'm using the .listFiles method to obtain my files. But how should the format on the second argument (queries) be?

TypeScript
const result = await storage.listFiles(
  'bucketID', // bucketId
  [{
    name: 'filename'
  }]
);

Link: https://appwrite.io/docs/references/cloud/client-web/storage

TL;DR
To query `storage.listFiles()`, developers should use `Query.contains` instead of `Query.contain`. The correct format for the second argument is an array of objects with key-value pairs for the query parameters. Check the documentation pages for more information: <https://appwrite.io/docs/products/databases/queries> and <https://appwrite.io/docs/references/cloud/client-web/storage>.
Isak
24 May, 2024, 15:38

Storage - How to query <storage>.listFiles()

Isak
24 May, 2024, 15:42

I tried

TypeScript
const result = await storage.listFiles(
    'bucketId',
    [
        Query.contain("name", "file")
    ],
);

But it says that contain doesn't exist on type Query, but on this page it does: https://appwrite.io/docs/products/databases/queries

Evdog
24 May, 2024, 15:51

Try contains

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more