You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 16, 2019. It is now read-only.
A react-native module for fetch file/image with custom headers, supports blob response data.
3
+
A react-native module for fetch file/image with custom headers, supports blob response data, and upload/download progress.
4
4
5
5
If you're dealing with image or file server that requires an `Authorization` token in the header, or you're having problem with `fetch` API when receiving blob data, you might try this module (this is also the reason why I made this).
6
6
@@ -10,13 +10,23 @@ This module enables you upload/download binary data in js, see [Examples](#user-
10
10
11
11
The source code is very simple, just an implementation of native HTTP request, supports both Android (uses awesome native library [AsyncHttpClient](https://github.com/AsyncHttpClient/async-http-client])) and IOS.
12
12
13
+
## Major Changes
14
+
15
+
| Version ||
16
+
|---|---|
17
+
| 0.3 | Upload/Download octet-stream and form-data |
18
+
| 0.4 | Add base-64 encode/decode library and API |
19
+
| 0.4.1 | Fixe upload form-data missing file extension problem on Android |
Headers of HTTP request, value of headers should be `stringified`, if you're uploading binary files, content-type should be `application/octet-stream` or `multipart/form-data`(see examples above).
129
160
#### body:`string | Array<Object>` (Optional)
130
161
Body of the HTTP request, body can either be a BASE64 string, or an array contains object elements, each element have 2 required property `name`, and `data`, and 1 optional property `filename`, once `filename` is set, content in `data` property will be consider as BASE64 string that will be converted into byte array later.
131
-
132
162
When body is a base64 string , this string will be converted into byte array in native code, and the request body will be sent as `application/octet-stream`.
133
163
164
+
### `fetch(...).progress(eventListener):Promise<FetchBlobResponse>` added in `0.4.2`
165
+
166
+
Register on progress event handler for a fetch request.
A function that triggers when there's data received/sent, first argument is the number of sent/received bytes, and second argument is expected total bytes number.
171
+
134
172
#### `base64`
135
173
136
174
A helper object simply uses [base-64](https://github.com/mathiasbynens/base64) for decode and encode BASE64 data.
@@ -152,7 +190,8 @@ When `fetch` success, it resolve a `FetchBlobResponse` object as first argument.
152
190
returns decoded base64 string (done in js context)
0 commit comments