Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 0f7c110

Browse files
committed
add android usage to readme.
1 parent dddf2f1 commit 0f7c110

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,48 @@ What if you want to append a file to form data ? Just like [upload a file from s
381381
})
382382
```
383383

384+
When you append files to form-data and you want to continue uploading while the app is in background on Android, you can use IntentService to upload by adding `multipartFileUpload` flag to config.
385+
386+
```js
387+
388+
RNFetchBlob.config({
389+
multipartFileUpload: true,
390+
})
391+
.fetch('POST', 'http://www.example.com/upload-form', {
392+
Authorization : "Bearer access-token",
393+
otherHeader : "foo",
394+
// this is required, otherwise it won't be process as a multipart/form-data request
395+
'Content-Type' : 'multipart/form-data',
396+
}, [
397+
// append field data from file path
398+
{
399+
name : 'avatar',
400+
filename : 'avatar.png',
401+
// Change BASE64 encoded data to a file path with prefix `RNFetchBlob-file://`.
402+
// Or simply wrap the file path with RNFetchBlob.wrap().
403+
data: RNFetchBlob.wrap(PATH_TO_THE_FILE)
404+
},
405+
{
406+
name : 'ringtone',
407+
filename : 'ring.mp3',
408+
// use custom MIME type
409+
type : 'application/mp3',
410+
// upload a file from asset is also possible in version >= 0.6.2
411+
data : RNFetchBlob.wrap(RNFetchBlob.fs.asset('default-ringtone.mp3'))
412+
}
413+
// elements without property `filename` will be sent as plain text
414+
{ name : 'name', data : 'user'},
415+
{ name : 'info', data : JSON.stringify({
416+
417+
tel : '12345678'
418+
})},
419+
]).then((resp) => {
420+
// ...
421+
}).catch((err) => {
422+
// ...
423+
})
424+
```
425+
384426
### Upload/Download progress
385427

386428
In `version >= 0.4.2` it is possible to know the upload/download progress. After `0.7.0` IOS and Android upload progress are also supported.

0 commit comments

Comments
 (0)