@better-s3/react 3.1049.0 → 3.1050.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 +13 -58
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,75 +1,30 @@
|
|
|
1
1
|
# @better-s3/react
|
|
2
2
|
|
|
3
|
-
Headless React hooks for S3 upload, download, and delete
|
|
3
|
+
Headless React hooks for S3 upload, download, and delete flows.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Full documentation: [better-s3-docs.vercel.app](https://better-s3-docs.vercel.app/docs/react)
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
pnpm add @better-s3/react @better-s3/
|
|
10
|
+
pnpm add @better-s3/react @better-s3/core
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { createS3Api } from "@better-s3/core";
|
|
17
|
-
|
|
18
|
-
const api = createS3Api();
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Hooks
|
|
22
|
-
|
|
23
|
-
| Hook | Use case |
|
|
24
|
-
| ------------------------ | --------------------------------------- |
|
|
25
|
-
| `useUploadControls` | Single file — picker + drag-and-drop |
|
|
26
|
-
| `useMultiUploadControls` | Multiple files — picker + drag-and-drop |
|
|
27
|
-
| `useUpload` | Single file — call `upload()` yourself |
|
|
28
|
-
| `useMultiUpload` | Batch — call `upload()` yourself |
|
|
29
|
-
| `useDownload` | Presigned URL → native browser download |
|
|
30
|
-
| `useFetchDownload` | Fetch with progress and cancel |
|
|
31
|
-
| `useDelete` | Two-step delete with confirmation |
|
|
32
|
-
|
|
33
|
-
### Upload — single file
|
|
34
|
-
|
|
35
|
-
```tsx
|
|
36
|
-
const { openFilePicker, inputProps, dropHandlers, progress, isUploading } =
|
|
37
|
-
useUploadControls({
|
|
38
|
-
api,
|
|
39
|
-
objectKey: (file) => `uploads/${file.name}`,
|
|
40
|
-
accept: ["image/*"],
|
|
41
|
-
maxFileSize: 10 * 1024 * 1024,
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// <input {...inputProps} />
|
|
45
|
-
// <div {...dropHandlers} onClick={openFilePicker}>…</div>
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Upload — multiple files
|
|
13
|
+
## Minimal setup
|
|
49
14
|
|
|
50
15
|
```tsx
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
api,
|
|
54
|
-
objectKey: (file) => `uploads/${file.name}`,
|
|
55
|
-
maxFiles: 5,
|
|
56
|
-
concurrentFiles: 3,
|
|
57
|
-
});
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Download
|
|
16
|
+
import { createS3Api } from "@better-s3/core";
|
|
17
|
+
import { S3Provider, useUploadControls } from "@better-s3/react";
|
|
61
18
|
|
|
62
|
-
|
|
63
|
-
const { download } = useDownload({ api });
|
|
64
|
-
download("uploads/photo.jpg", "photo.jpg");
|
|
65
|
-
```
|
|
19
|
+
const client = createS3Api();
|
|
66
20
|
|
|
67
|
-
|
|
21
|
+
// App root
|
|
22
|
+
<S3Provider client={client}>{children}</S3Provider>;
|
|
68
23
|
|
|
69
|
-
|
|
70
|
-
const {
|
|
71
|
-
|
|
72
|
-
|
|
24
|
+
// In a component
|
|
25
|
+
const { openFilePicker, inputProps } = useUploadControls({
|
|
26
|
+
objectKey: (file) => `uploads/${file.name}`,
|
|
27
|
+
});
|
|
73
28
|
```
|
|
74
29
|
|
|
75
30
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-s3/react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1050.0",
|
|
4
4
|
"description": "React hooks for S3-compatible file uploads, downloads, and deletes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"s3",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@better-s3/core": "3.
|
|
36
|
+
"@better-s3/core": "3.1050.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": ">=18"
|