|
|
|
|
256
|
})
|
256
|
})
|
257
|
```
|
257
|
```
|
258
|
|
258
|
|
259
|
-What if you want to upload a file in some field ? Just like [upload a file from storage](#user-content-upload-a-file-from-storage) example, wrap `data` by `wrap` API (this feature is only available for `version >= v0.5.0`)
|
|
|
|
|
259
|
+What if you want to upload a file in some field ? Just like [upload a file from storage](#user-content-upload-a-file-from-storage) example, wrap `data` by `wrap` API (this feature is only available for `version >= v0.5.0`). On version >= `0.6.2`, it is possible to set custom MIME type when appending file to form data.
|
260
|
|
260
|
|
261
|
```js
|
261
|
```js
|
262
|
|
262
|
|
|
|
|
|
274
|
// Or simply wrap the file path with RNFetchBlob.wrap().
|
274
|
// Or simply wrap the file path with RNFetchBlob.wrap().
|
275
|
data: RNFetchBlob.wrap(PATH_TO_THE_FILE)
|
275
|
data: RNFetchBlob.wrap(PATH_TO_THE_FILE)
|
276
|
},
|
276
|
},
|
|
|
277
|
+ {
|
|
|
278
|
+ name : 'ringtone',
|
|
|
279
|
+ filename : 'ring.mp3',
|
|
|
280
|
+ // use custom MIME type
|
|
|
281
|
+ type : 'application/mp3',
|
|
|
282
|
+ // upload a file from asset is also possible in version >= 0.6.2
|
|
|
283
|
+ data : RNFetchBlob.wrap(RNFetchBlob.fs.asset('default-ringtone.mp3'))
|
|
|
284
|
+ }
|
277
|
// elements without property `filename` will be sent as plain text
|
285
|
// elements without property `filename` will be sent as plain text
|
278
|
{ name : 'name', data : 'user'},
|
286
|
{ name : 'name', data : 'user'},
|
279
|
{ name : 'info', data : JSON.stringify({
|
287
|
{ name : 'info', data : JSON.stringify({
|
|
|
|
|
289
|
|
297
|
|
290
|
#### Upload/Download progress
|
298
|
#### Upload/Download progress
|
291
|
|
299
|
|
292
|
-In `version >= 0.4.2` it is possible to know the upload/download progress.
|
|
|
|
|
300
|
+In `version >= 0.4.2` it is possible to know the upload/download progress. On Anroid, only download progress is supported. See [wiki](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetchprogresseventlistenerpromisernfetchblobresponse) for more information.
|
293
|
|
301
|
|
294
|
```js
|
302
|
```js
|
295
|
RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
|
303
|
RNFetchBlob.fetch('POST', 'http://www.example.com/upload', {
|
|
|
|
|
394
|
File access APIs were made when developing `v0.5.0`, which helping us write tests, and was not planned to be a part of this module. However I realized that, it's hard to find a great solution to manage cached files, every one who use this moudle may need those APIs for there cases.
|
402
|
File access APIs were made when developing `v0.5.0`, which helping us write tests, and was not planned to be a part of this module. However I realized that, it's hard to find a great solution to manage cached files, every one who use this moudle may need those APIs for there cases.
|
395
|
|
403
|
|
396
|
File Access APIs
|
404
|
File Access APIs
|
397
|
-
|
|
|
|
|
405
|
+- [asset (0.6.0)](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#asset)
|
398
|
- [dirs](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#dirs)
|
406
|
- [dirs](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#dirs)
|
399
|
- [createFile](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#createfilepath-data-encodingpromise)
|
407
|
- [createFile](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#createfilepath-data-encodingpromise)
|
400
|
- [writeFile (0.6.0)](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#writefilepathstring-contentstring--array-encodingstring-appendbooleanpromise)
|
408
|
- [writeFile (0.6.0)](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#writefilepathstring-contentstring--array-encodingstring-appendbooleanpromise)
|
|
|
|
|
539
|
|
547
|
|
540
|
| Version | |
|
548
|
| Version | |
|
541
|
|---|---|
|
549
|
|---|---|
|
|
|
550
|
+| 0.6.2 | Add support of asset file and camera roll files, Support custom MIME type when sending multipart request, thanks @smartt |
|
542
|
| 0.6.1 | Fix #37 progress report API issue on IOS |
|
551
|
| 0.6.1 | Fix #37 progress report API issue on IOS |
|
543
|
| 0.6.0 | Add readFile and writeFile API for easier file access, also added Android download manager support. |
|
552
|
| 0.6.0 | Add readFile and writeFile API for easier file access, also added Android download manager support. |
|
544
|
| 0.5.8 | Fix #33 PUT request will always be sent as POST on Android |
|
553
|
| 0.5.8 | Fix #33 PUT request will always be sent as POST on Android |
|