@@ -284,6 +284,60 @@ const { blobs } = await store.list({ prefix: 'some' })
284
284
console .log (blobs)
285
285
```
286
286
287
+ Optionally, you can choose to group blobs together under a common prefix and then browse them hierarchically when
288
+ listing a store.
289
+
290
+ To do this, you must use the ` / ` character in your keys to separate keys into multiple levels.
291
+
292
+ Take the following list of keys as an example:
293
+
294
+ ```
295
+ cats/garfield.jpg
296
+ cats/tom.jpg
297
+ mice/jerry.jpg
298
+ mice/mickey.jpg
299
+ pink-panther.jpg
300
+ ```
301
+
302
+ By default, calling ` store.list() ` will return all five keys.
303
+
304
+ ``` javascript
305
+ const { blobs } = await store .list ()
306
+
307
+ // [
308
+ // { etag: "etag1", key: "cats/garfield.jpg" },
309
+ // { etag: "etag2", key: "cats/tom.jpg" },
310
+ // { etag: "etag3", key: "mice/jerry.jpg" },
311
+ // { etag: "etag4", key: "mice/mickey.jpg" },
312
+ // { etag: "etag5", key: "pink-panther.jg" },
313
+ // ]
314
+ console .log (blobs)
315
+ ```
316
+
317
+ But if you want to list entries hierarchically, use the ` directories ` parameter.
318
+
319
+ ``` javascript
320
+ const { blobs , directories } = await store .list ({ directories: true })
321
+
322
+ // [ { etag: "etag1", key: "pink-panther.jpg" } ]
323
+ console .log (blobs)
324
+
325
+ // [ "cats", "mice" ]
326
+ console .log (directories)
327
+ ```
328
+
329
+ To drill down into a directory and get a list of its items, you can use the directory name as the ` prefix ` value.
330
+
331
+ ``` javascript
332
+ const { blobs , directories } = await store .list ({ prefix: ' mice/' })
333
+
334
+ // [ { etag: "etag3", key: "mice/jerry.jpg" }, { etag: "etag4", key: "mice/mickey.jpg" } ]
335
+ console .log (blobs)
336
+
337
+ // [ ]
338
+ console .log (directories)
339
+ ```
340
+
287
341
## Contributing
288
342
289
343
Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or
0 commit comments