-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Classes
A set of configurations that will be injected into a fetch
method, with the following properties.
0.8.0
Set timeout of the request (in milliseconds).
0.5.6
Set this property to true
to display a network indicator on status bar, this feature is only supported on IOS.
0.5.3
Set this property to true
will allow the request create connection with server have self-signed SSL certification. This is not recommended to use in production.
Set this property to true
will makes response data of the fetch
stored in a temp file, by default the temp file will stored in App's own root folder with file name template RNFetchBlob_tmp${timestamp}
.
Set this property to change temp file extension that created by fetch
response data.
When this property has value, fetch
API will try to store response data in the path ignoring fileCache
and appendExt
property.
This is an Android only property, it should be an object with the following properties :
- useDownloadManager : download file using Android download manager or not.
- title : title of the file
- description : File description of the file.
- path : The destination which the file will be downloaded, it SHOULD be a location on external storage (DCIMDir).
- mime : MIME type of the file. By default is
text/plain
- mediaScannable : A
boolean
value, see [Officail Document](https://developer.android.com/reference/android/app/DownloadManager.html#addCompletedDownload(java.lang.String, java.lang.String, boolean, java.lang.String, java.lang.String, long, boolean)) - notification : A
boolean
value decide whether show a notification when download complete.
When fetch
success, it resolve a FetchBlobResponse
object as first argument. FetchBlobResponse
object has the following methods (these method are synchronous, so you might take quite a performance impact if the file is big)
returns an dictionary contains properties such as status
, headers
, respType
(referenced by XMLHttpRequest), rnfbEncode
.
returns base64 string of response data (done in native context)
returns json parsed object (done in js context)
returns decoded base64 string (done in js context)
returns file path if the response data is cached in file
return a promise that resolves response data when possible.
return a promise that resolves a readStream
object when possible.
when the response data is cached in a file, this method adds the file into the session. The following usages are equivalent.
RNFetchBlob.session('session-name').add(resp.path())
// or
resp.session('session-name')
info():RNFetchBlobResponseInfo
This method returns an object contains response information like status code, headers.
0.8.0
Response detail information object like status, headers.
0.8.0
An dictionary contains headers.
Status code of the response.
XMLHttpRequest response type.
RNFetchBlob.fetch response type, in RNFetchBlob.fetch response, there will always 2 kinds of response data, path
and base64
.
0.5.0
Statistic data of a file, see the following sample object. This object usually comes from stat and lstat API
{
// file name
filename : 'foo.png',
// folder of the file or the folder itself
path : '/path/to/the/file/wihout/file/name/',
// size in byte
size : 4901,
// `file` or `directory`
type : 'file',
// last modified timestamp
lastModified : 141323298
}
A class inherits Promise
, it has extra method like progress
, uploadProgress
, and cancel
which can help managing an asynchronous task's state.
0.8.0
Cancel the request when invoke this method.
0.5.0
Add an event listener which triggers when data receiving from server.
0.8.0
Add an event listener which triggers when data chunks sent to server.