| 39 | */ |
| 40 | listFiles(bucketId: string, queries?: string[], search?: string, total?: boolean): Promise<Models.FileList>; |
| 41 | listFiles( |
| 42 | paramsOrFirst: { bucketId: string, queries?: string[], search?: string, total?: boolean } | string, |
| 43 | ...rest: [(string[])?, (string)?, (boolean)?] |
| 44 | ): Promise<Models.FileList> { |
| 45 | let params: { bucketId: string, queries?: string[], search?: string, total?: boolean }; |
| 46 | |
| 47 | if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) { |
| 48 | params = (paramsOrFirst || {}) as { bucketId: string, queries?: string[], search?: string, total?: boolean }; |
| 49 | } else { |
| 50 | params = { |
| 51 | bucketId: paramsOrFirst as string, |
| 52 | queries: rest[0] as string[], |
| 53 | search: rest[1] as string, |
| 54 | total: rest[2] as boolean |
| 55 | }; |
| 56 | } |
| 57 | |
| 58 | const bucketId = params.bucketId; |
| 59 | const queries = params.queries; |
| 60 | const search = params.search; |
| 61 | const total = params.total; |
| 62 | |
| 63 | if (typeof bucketId === 'undefined') { |
| 64 | throw new AppwriteException('Missing required parameter: "bucketId"'); |
| 65 | } |
| 66 | |
| 67 | const apiPath = '/storage/buckets/{bucketId}/files'.replace('{bucketId}', bucketId); |
| 68 | const payload: Payload = {}; |
| 69 | |
| 70 | if (typeof queries !== 'undefined') { |
| 71 | payload['queries'] = queries; |
| 72 | } |
| 73 | |
| 74 | if (typeof search !== 'undefined') { |
| 75 | payload['search'] = search; |
| 76 | } |
| 77 | |
| 78 | if (typeof total !== 'undefined') { |
| 79 | payload['total'] = total; |
| 80 | } |
| 81 | |
| 82 | const uri = new URL(this.client.config.endpoint + apiPath); |
| 83 | return this.client.call('get', uri, { |
| 84 | }, payload); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](https://appwrite.io/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. |