You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/file-storage/CHANGELOG.md
+30-1Lines changed: 30 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,35 @@ The following `options` are available:
13
13
-`limit`: The maximum number of files to return
14
14
-`prefix`: Only return keys that start with this string
15
15
16
+
For example, to list all files under keys that start with `user123/`:
17
+
18
+
```ts
19
+
let result =awaitstorage.list({ prefix: 'user123/' });
20
+
console.log(result.files);
21
+
// [
22
+
// { key: "user123/..." },
23
+
// { key: "user123/..." },
24
+
// ...
25
+
// ]
26
+
```
27
+
28
+
`result.files` will be an array of `{ key: string }` objects. To include metadata about each file, use `includeMetadata: true` in your `options`:
29
+
30
+
```ts
31
+
let result =awaitstorage.list({ prefix: 'user123/', includeMetadata: true });
32
+
console.log(result.files);
33
+
// [
34
+
// {
35
+
// key: "user123/..."
36
+
// lastModified: 1737955705270,
37
+
// name: "hello.txt"
38
+
// size: 16,
39
+
// type: "text/plain"
40
+
// },
41
+
// ...
42
+
// ]
43
+
```
44
+
16
45
Pagination is done via an opaque `cursor` property in the list result object. If it is not `undefined`, there are more files to list. You can list them by passing the `cursor` back in the `options` object on the next call.
17
46
18
47
```ts
@@ -25,7 +54,7 @@ if (result.cursor !== undefined) {
25
54
}
26
55
```
27
56
28
-
Objects in the `files` array have only a `key` property by default. If you pass `includeMetadata: true`in the options, they will also have `lastModified`, `name`, `size`, and `type` properties.
57
+
Use the `limit` option to limit how many results you get back in the `files` array.
Copy file name to clipboardExpand all lines: packages/file-storage/src/lib/file-storage.ts
+31-6Lines changed: 31 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -26,9 +26,36 @@ export interface FileStorage {
26
26
* - `limit`: The maximum number of files to return
27
27
* - `prefix`: Only return keys that start with this string
28
28
*
29
-
* Pagination is done via an opaque `cursor` property in the list result object. If it is not
30
-
* `undefined`, there are more files to list. You can list them by passing the `cursor` back
31
-
* in the `options` object on the next call.
29
+
* For example, to list all files under keys that start with `user123/`:
30
+
*
31
+
* ```ts
32
+
* let result = await storage.list({ prefix: 'user123/' });
33
+
* console.log(result.files);
34
+
* // [
35
+
* // { key: "user123/..." },
36
+
* // { key: "user123/..." },
37
+
* // ...
38
+
* // ]
39
+
* ```
40
+
*
41
+
* `result.files` will be an array of `{ key: string }` objects. To include metadata about each file, use `includeMetadata: true` in your `options`:
42
+
*
43
+
* ```ts
44
+
* let result = await storage.list({ prefix: 'user123/', includeMetadata: true });
45
+
* console.log(result.files);
46
+
* // [
47
+
* // {
48
+
* // key: "user123/..."
49
+
* // lastModified: 1737955705270,
50
+
* // name: "hello.txt"
51
+
* // size: 16,
52
+
* // type: "text/plain"
53
+
* // },
54
+
* // ...
55
+
* // ]
56
+
* ```
57
+
*
58
+
* Pagination is done via an opaque `cursor` property in the list result object. If it is not `undefined`, there are more files to list. You can list them by passing the `cursor` back in the `options` object on the next call.
32
59
*
33
60
* ```ts
34
61
* let result = await storage.list();
@@ -40,9 +67,7 @@ export interface FileStorage {
40
67
* }
41
68
* ```
42
69
*
43
-
* Objects in the `files` array have only a `key` property by default. If you pass
44
-
* `includeMetadata: true` in the options, they will also have `lastModified`, `name`, `size`, and
45
-
* `type` properties.
70
+
* Use the `limit` option to limit how many results you get back in the `files` array.
46
71
*
47
72
* @param options Options for the list operation
48
73
* @returns An object with an array of `files` and an optional `cursor` property
0 commit comments