Skip to content
wkh237 edited this page Aug 3, 2016 · 20 revisions

Index


RNFetchBlobConfig

A set of configurations that will be injected into a fetch method, with the following properties.

timeout:number

0.8.0

Set timeout of the request (in milliseconds).

indicator:boolean

0.5.6

Set this property to true to display a network indicator on status bar, this feature is only supported on IOS.

trusty:boolean

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.

fileCache:boolean

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}.

appendExt:string

Set this property to change temp file extension that created by fetch response data.

path:string

When this property has value, fetch API will try to store response data in the path ignoring fileCache and appendExt property.

addAndroidDownloads:object (Android only)

This is an Android only property, it should be an object with the following properties :


RNFetchBlobResponse

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)

base64():string

returns base64 string of response data (done in native context)

json():object

returns json parsed object (done in js context)

text():string

returns decoded base64 string (done in js context)

path():string

returns file path if the response data is cached in file

readFile(encoding:string):Promise

return a promise that resolves response data when possible.

readStream(encoding:string, bufferSize:number):Promise

return a promise that resolves a readStream object when possible.

session(name:string):RNFetchBlobSession

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')

This method returns an object contains response information like status code, headers.

0.8.0

Response detail information object like status, headers.


RNFetchBlobResponseInfo

0.8.0

headers : any

status : number

respType : 'text' | 'blob' | '' | 'json'

rnfbEncode : 'path' | 'base64' | 'ascii' | 'utf8'


RNFetchBlobStat

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
}
Clone this wiki locally