Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Madhav Varshney edited this pageJan 24, 2019 ·40 revisions

Index

RNFetchBlobAndroidDownloadOption

0.10.6

Option object for Android Download manager API likeandroid.addCompleteDownload

title:string

Title string to be displayed when the file added toDownloads app.

description:string

File description to be displayed when the file added toDownloads app.

mime:string

MIME string of the file.

path:string

URI string of the file.

showNotification:boolean

Boolean value that determines if notification will be displayed.

RNFetchBlobConfig

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

IOSBackgroundTask:boolean

0.10.6

Set this flag totrue if you wish the request can last as long as possible even the app entering background. Notice that when enable background task, thetimeout does not take effect, also the redirect record will be empty. See#368

overwrite:boolean

0.10.0

When this property istrue, the downloaded data will overwrite the existing file. (true by default)

// overwrite == trueRNFetchBlob.config({path :PATH_OF_AN_EXISTING_FILE,overwrite :true}).fetch('GET','http://www.example.com').then((res)=>{// the file at path `PATH_OF_AN_EXISTING_FILE` will be overwrite by// the response data from `http://www.example.com`})// overwrite == falseRNFetchBlob.config({path :PATH_OF_AN_EXISTING_FILE,overwrite :false}).fetch('GET','http://www.example.com').then((res)=>{// the response data from `http://www.example.com` will append// to the file at path PATH_OF_AN_EXISTING_FILE instead of replace it})

timeout:number

0.8.0

Set timeout of the request (in milliseconds).

indicator:boolean

0.5.6

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

trusty:boolean

0.5.3

Set this property totrue 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 totrue will makes response data of thefetch stored in a temp file, by default the temp file will stored in App's own root folder with file name templateRNFetchBlob_tmp${timestamp}.

appendExt:string

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

path:string

When this property has value,fetch API will try to store response data in the path ignoringfileCache andappendExt property.

addAndroidDownloads:object (Android only)

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 istext/plain
  • mediaScannable : Aboolean 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 : Aboolean value decide whether show a notification when download complete.

Notice : Android Download Manager only supportsGET requests

followRedirect:boolean (detault = true)

0.10.2-beta.6

Property represents if it automatically follow redirects, default value istrue.

RNFetchBlobResponse

Whenfetch success, it resolve aFetchBlobResponse 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<RNFetchBlobSession>

return a promise that resolves areadStream 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())// orresp.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

Properties

headers : any

An dictionary contains headers.

status : number

Status code of the response.

respType : 'text' | 'blob' | '' | 'son'

XMLHttpRequest response type.

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

RNFetchBlob.fetch response type, in RNFetchBlob.fetch response, when the response data is stored to file system, it should bepath otherwise it depends on the response data, if the data can be encoded into UTF8 string it will beutf8 otherwisebase64.

RNFetchBlobStat

0.5.0

Statistic data of a file, see the following sample object. This object usually comes fromstat andlstat API

{// file namefilename :'foo.png',// folder of the file or the folder itselfpath :'/path/to/the/file/without/file/name/',// size, in bytessize :4901,// `file` or `directory`type :'file',// last modified timestamplastModified :141323298}

StatefulPromise

A class inheritsPromise, it has extra methods likeprogress,uploadProgress, andcancel which can help managing an asynchronous task's state.

Methods

cancel(): StatefulPromise

0.8.0

Cancel the request when invoking this method.

stateChange(serverResponse => void): StatefulPromise

0.9.0

Add an event listener which will be triggered when StatefulPromise's state changing.

progress((received, total) => void)

0.5.0

Add an event listener which triggers when data receiving from server.

progress(config, (received, total) => void)

0.9.6

Add an event listener with custom configuration,see usage.

uploadProgress((sent, total) => void)

0.8.0

Add an event listener which triggers when data chunks sent to server.

uploadProgress(config ,(sent, total) => void)

Add an event listener with custom configuration,see usage.

expire(() => void)

0.10.0

An IOS only API, when IOS app turns into background network tasks will be terminated after ~180 seconds, in order to handle these expired tasks, you can register an event handler, which will be called after the app become active.

RNFetchBlob.fetch('GET','http://example.com').expire(()=>{console.log('task expired !!')}).then(()=>{ ...})

RNFetchBlobReadStream

0.5.0

A file stream instance created byfs.readStream

Methods

open()

A file stream will NOT open automatically, invoke this method to start read chunks from the file.

onData((chunk:string | Array<number>) => void)

Register an event handler handles the chunks read from the stream, when usingascii encodingchunk will be an Array contains number 0-255, otherwise it's a string.

onError((detail) => void)

Register an event handler handles the chunks read from the stream, when usingascii encodingchunk will be an Array contains number 0-255, otherwise it's a string.

onEnd(() => void)

Register an event handler which invoked when stream reaches end of file.

RNFetchBlobWriteStream

0.5.0

A file stream instance created byfs.writeStream

Methods

write(data: string | Array<number>): Promise<void>

Writes the given data to the stream. If the encoding is "ascii" the data is expected to be an array of 0..255 numbers, otherwise a string (encoding "utf8" and "base64").

close(): Promise<void>

Closes the stream.

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp