1
- ** Zero dependency, total control, file upload hook for React.**
1
+ ** Zero dependency, total control, file upload hook for React with upload progress .**
2
2
3
3
This has been rewritten into a single file for simplicity, and the function signature has gotten much smaller.
4
4
@@ -24,7 +24,7 @@ Here's a basic example of uploading a single file to a url
24
24
const MyComponent = () => {
25
25
let [upload, { progress, done, loading }] = useUpload (({ files }) => ({
26
26
method: " PUT" ,
27
- url: url ,
27
+ url: " http://localhost:4000 " ,
28
28
body: files[0 ],
29
29
}));
30
30
@@ -56,7 +56,7 @@ const MyComponent = () => {
56
56
57
57
return {
58
58
method: " PUT" ,
59
- url: url ,
59
+ url: " http://localhost:4000 " ,
60
60
body: formData,
61
61
};
62
62
});
@@ -68,7 +68,7 @@ const MyComponent = () => {
68
68
type= " file"
69
69
onChange= {(e ) => {
70
70
if (e .target .files ) {
71
- upload ({ file : e .target .files [ 0 ] });
71
+ upload ({ files : e .target .files });
72
72
}
73
73
}}
74
74
/ >
@@ -89,7 +89,7 @@ const MyComponent = () => {
89
89
90
90
return {
91
91
method: " PUT" ,
92
- url: url ,
92
+ url: " http://localhost:4000 " ,
93
93
body: formData,
94
94
headers: { Authorization: " test" },
95
95
};
@@ -102,7 +102,7 @@ const MyComponent = () => {
102
102
type= " file"
103
103
onChange= {(e ) => {
104
104
if (e .target .files ) {
105
- upload ({ file : e .target .files [ 0 ] });
105
+ upload ({ files : e .target .files });
106
106
}
107
107
}}
108
108
/ >
@@ -125,7 +125,7 @@ const MyComponent = () => {
125
125
126
126
return {
127
127
method: " PUT" ,
128
- url: url ,
128
+ url: " http://localhost:4000 " ,
129
129
body: formData,
130
130
headers: { Authorization: " test" },
131
131
};
@@ -138,7 +138,7 @@ const MyComponent = () => {
138
138
type= " file"
139
139
onChange= {(e ) => {
140
140
if (e .target .files ) {
141
- upload ({ file : e .target .files [ 0 ] });
141
+ upload ({ files : e .target .files });
142
142
}
143
143
}}
144
144
/ >
@@ -172,7 +172,7 @@ const MyComponent = () => {
172
172
return {
173
173
method: " PUT" ,
174
174
url: url,
175
- // send a single file in the body to the storage bucker
175
+ // send a single file in the body to the storage bucket
176
176
body: files[0 ],
177
177
};
178
178
});
@@ -190,7 +190,7 @@ const MyComponent = () => {
190
190
type= " file"
191
191
onChange= {(e ) => {
192
192
if (e .target .files ) {
193
- upload ({ file : e .target .files [ 0 ] });
193
+ upload ({ files : e .target .files });
194
194
}
195
195
}}
196
196
/ >
0 commit comments