firebase-storage-kit 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -82
- package/dist/chunk-PBO3CMOD.js +766 -0
- package/dist/chunk-PBO3CMOD.js.map +1 -0
- package/dist/firebase-storage-manager-DT6lxmUD.d.ts +260 -0
- package/dist/index.d.ts +8 -264
- package/dist/index.js +1 -683
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +29 -0
- package/dist/react/index.js +115 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +29 -16
package/README.md
CHANGED
|
@@ -2,21 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Storage manager for Firebase Storage with uploads, progress tracking, batch uploads, and file query helpers.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Full documentation:** [firebase-storage-kit.vercel.app/docs](https://firebase-storage-kit.vercel.app/docs)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install firebase-storage-kit
|
|
10
|
+
npm install firebase firebase-storage-kit
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
yarn add firebase-storage-kit
|
|
17
|
-
pnpm add firebase-storage-kit
|
|
18
|
-
bun add firebase-storage-kit
|
|
19
|
-
```
|
|
13
|
+
Also works with Yarn, pnpm, or Bun. See [Installation](https://firebase-storage-kit.vercel.app/docs/getting-started/installation) for all package managers.
|
|
20
14
|
|
|
21
15
|
## Quick start
|
|
22
16
|
|
|
@@ -38,84 +32,24 @@ handle.on("success", (upload) => {
|
|
|
38
32
|
});
|
|
39
33
|
```
|
|
40
34
|
|
|
41
|
-
###
|
|
42
|
-
|
|
43
|
-
```ts
|
|
44
|
-
const batch = manager.uploadFiles(
|
|
45
|
-
files,
|
|
46
|
-
(file) => ({ path: `uploads/${file.name}` }),
|
|
47
|
-
{ concurrency: 3, continueOnError: true },
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
batch.on("success", (snapshot) => {
|
|
51
|
-
console.log(snapshot.completedCount, snapshot.failedCount);
|
|
52
|
-
});
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Subscriptions (manager state)
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
const unsubscribe = manager.subscribe((state) => {
|
|
59
|
-
console.log(state.uploads, state.batches);
|
|
60
|
-
});
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Custom metadata
|
|
64
|
-
|
|
65
|
-
Attach app-specific metadata when uploading. Read it back later with `getMetadata`:
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
const handle = manager.uploadFile(file, {
|
|
69
|
-
path: `uploads/${file.name}`,
|
|
70
|
-
customMetadata: {
|
|
71
|
-
owner: "user-123",
|
|
72
|
-
source: "mobile-app",
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const meta = await manager.getMetadata(`uploads/${file.name}`);
|
|
77
|
-
console.log(meta.customMetadata?.owner);
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Works with batch uploads too — use `customMetadata` in the `UploadOptions` for each file.
|
|
35
|
+
### React
|
|
81
36
|
|
|
82
|
-
|
|
37
|
+
```tsx
|
|
38
|
+
import { useStorageManager, useUpload } from "firebase-storage-kit/react";
|
|
83
39
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
- **Security rules.** Who can read or write metadata is controlled by your Firebase Storage security rules — configure them if metadata is sensitive.
|
|
88
|
-
|
|
89
|
-
### Upload retries
|
|
90
|
-
|
|
91
|
-
Uploads retry transient failures automatically (3 retries by default, exponential backoff with jitter). Pass `retry: false` to disable, or customize:
|
|
92
|
-
|
|
93
|
-
```ts
|
|
94
|
-
const handle = manager.uploadFile(file, {
|
|
95
|
-
path: `uploads/${file.name}`,
|
|
96
|
-
retry: { maxRetries: 5, initialDelayMs: 700 },
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
handle.on("retry", ({ attempt, maxAttempts, delayMs, error }) => {
|
|
100
|
-
console.log(`Retry ${attempt}/${maxAttempts} in ${delayMs}ms`, error.message);
|
|
101
|
-
});
|
|
40
|
+
const manager = useStorageManager(storage);
|
|
41
|
+
const handle = manager.uploadFile(file, { path: `uploads/${file.name}` });
|
|
42
|
+
const upload = useUpload(handle);
|
|
102
43
|
```
|
|
103
44
|
|
|
104
|
-
|
|
45
|
+
See [React hooks](https://firebase-storage-kit.vercel.app/docs/guides/react-hooks).
|
|
105
46
|
|
|
106
|
-
|
|
107
|
-
const exists = await manager.exists("uploads/photo.jpg");
|
|
108
|
-
|
|
109
|
-
if (exists) {
|
|
110
|
-
const meta = await manager.getMetadata("uploads/photo.jpg");
|
|
111
|
-
const url = await manager.getDownloadURL("uploads/photo.jpg");
|
|
112
|
-
console.log(meta.size, url);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
await manager.delete("uploads/old.jpg");
|
|
116
|
-
```
|
|
47
|
+
## Learn more
|
|
117
48
|
|
|
118
|
-
|
|
49
|
+
- [Single upload](https://firebase-storage-kit.vercel.app/docs/getting-started/single-upload)
|
|
50
|
+
- [Batch uploads](https://firebase-storage-kit.vercel.app/docs/guides/batch-uploads)
|
|
51
|
+
- [API reference](https://firebase-storage-kit.vercel.app/docs/api/storage-manager)
|
|
52
|
+
- [Troubleshooting](https://firebase-storage-kit.vercel.app/docs/troubleshooting)
|
|
119
53
|
|
|
120
54
|
## License
|
|
121
55
|
|