File tree 3 files changed +14
-2
lines changed 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,12 @@ abortUpload('file://some-local-file.jpg');
105
105
<td>Optional</td>
106
106
<td>The HTTP method for the request. Defaults to "POST".</td>
107
107
</tr >
108
+ <tr >
109
+ <td>data</td>
110
+ <td>object</td>
111
+ <td>Optional</td>
112
+ <td>An object of additional FormData fields to be set with the request.</td>
113
+ </tr >
108
114
<tr >
109
115
<td>headers</td>
110
116
<td>Headers</td>
@@ -163,7 +169,7 @@ useFileUpload({ headers });
163
169
```
164
170
165
171
</td >
166
- </tr >
172
+ </tr >
167
173
<tr >
168
174
<td>onError</td>
169
175
<td>function</td>
@@ -196,7 +202,7 @@ useFileUpload({ headers });
196
202
```
197
203
198
204
</td >
199
- </tr >
205
+ </tr >
200
206
</tbody >
201
207
</table >
202
208
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export default function useFileUpload<T extends UploadItem = UploadItem>({
12
12
method = 'POST' ,
13
13
headers,
14
14
timeout,
15
+ data,
15
16
onProgress,
16
17
onDone,
17
18
onError,
@@ -26,6 +27,10 @@ export default function useFileUpload<T extends UploadItem = UploadItem>({
26
27
const formData = new FormData ( ) ;
27
28
formData . append ( field , item ) ;
28
29
30
+ if ( data )
31
+ for ( const key in data )
32
+ formData . append ( key , data [ key ] ) ;
33
+
29
34
const xhr = new XMLHttpRequest ( ) ;
30
35
31
36
xhr . open ( method , url ) ;
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export type FileUploadOptions<T extends UploadItem = UploadItem> = {
33
33
method ?: string ;
34
34
headers ?: Headers ;
35
35
timeout ?: number ;
36
+ data ?: { [ key : string ] : string } ;
36
37
onProgress ?: ( data : OnProgressData < T > ) => void ;
37
38
onDone ?: ( data : OnDoneData < T > ) => void ;
38
39
onError ?: ( data : OnErrorData < T > ) => void ;
You can’t perform that action at this time.
0 commit comments