Skip to content

Commit 0a5b1f2

Browse files
committed
Updated doc comment and changelog
1 parent bbe216c commit 0a5b1f2

File tree

2 files changed

+61
-7
lines changed

2 files changed

+61
-7
lines changed

packages/file-storage/CHANGELOG.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ The following `options` are available:
1313
- `limit`: The maximum number of files to return
1414
- `prefix`: Only return keys that start with this string
1515

16+
For example, to list all files under keys that start with `user123/`:
17+
18+
```ts
19+
let result = await storage.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 = await storage.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+
1645
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.
1746

1847
```ts
@@ -25,7 +54,7 @@ if (result.cursor !== undefined) {
2554
}
2655
```
2756

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.
2958

3059
## v0.5.0 (2025-01-25)
3160

packages/file-storage/src/lib/file-storage.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,36 @@ export interface FileStorage {
2626
* - `limit`: The maximum number of files to return
2727
* - `prefix`: Only return keys that start with this string
2828
*
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.
3259
*
3360
* ```ts
3461
* let result = await storage.list();
@@ -40,9 +67,7 @@ export interface FileStorage {
4067
* }
4168
* ```
4269
*
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.
4671
*
4772
* @param options Options for the list operation
4873
* @returns An object with an array of `files` and an optional `cursor` property

0 commit comments

Comments
 (0)