Socket
Socket
Sign inDemoInstall

rn-fetch-blob

Package Overview
Dependencies
12
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.11.2 to 0.12.0

69

index.d.ts

@@ -359,3 +359,3 @@ // Type definitions for react-native-fetch-blob 0.10

appendFile(path: string, data: string | number[], encoding?: Encoding): Promise<void>;
appendFile(path: string, data: string | number[], encoding?: Encoding | "uri"): Promise<number>;

@@ -403,2 +403,3 @@ /**

PictureDir: string;
LibraryDir: string;
MusicDir: string;

@@ -437,3 +438,3 @@ MovieDir: string;

type Encoding = "utf8" | "ascii" | "base64";
export type Encoding = "utf8" | "ascii" | "base64";

@@ -456,2 +457,29 @@ /* tslint:disable-next-line interface-name*/

export interface AndroidDownloadOption {
/**
* Title string to be displayed when the file added to Downloads app.
*/
title: string
/**
* File description to be displayed when the file added to Downloads app.
*/
description: string
/**
* MIME string of the file.
*/
mime: string
/**
* URI string of the file.
*/
path: string
/**
* Boolean value that determines if notification will be displayed.
*/
showNotification: boolean
}
export interface AndroidApi {

@@ -465,2 +493,21 @@ /**

actionViewIntent(path: string, mime: string): Promise<any>;
/**
*
* This method brings up OS default file picker and resolves a file URI when the user selected a file.
* However, it does not resolve or reject when user dismiss the file picker via pressing hardware back button,
* but you can still handle this behavior via AppState.
* @param mime MIME type filter, only the files matches the MIME will be shown.
*/
getContentIntent(mime: string): Promise<any>;
/**
* Using this function to add an existing file to Downloads app.
* @param options An object that for setting the title, description, mime, and notification of the item.
*/
addCompleteDownload(options: AndroidDownloadOption): Promise<void>;
getSDCardDir(): Promise<string>;
getSDCardApplicationDir(): Promise<string>;
}

@@ -554,2 +601,12 @@

/**
* Set this property to true will only do requests through the WiFi interface, and fail otherwise.
*/
wifiOnly?: boolean;
/**
* Set this property so redirects are not automatically followed.
*/
followRedirect?: boolean;
/**
* Set this property to true will makes response data of the fetch stored in a temp file, by default the temp

@@ -615,7 +672,9 @@ * file will stored in App's own root folder with file name template RNFetchBlob_tmp${timestamp}.

taskId: string;
state: number;
state: string;
headers: any;
redirects: string[];
status: number;
respType: "text" | "blob" | "" | "json";
rnfbEncode: "path" | "base64" | "ascii" | "utf8";
timeout: boolean;
}

@@ -633,4 +692,4 @@

export declare class RNFetchBlobStat {
lastModified: string;
size: string;
lastModified: number;
size: number;
type: "directory" | "file";

@@ -637,0 +696,0 @@ path: string;

@@ -107,3 +107,9 @@ // Copyright 2016 wkh237@github. All rights reserved.

* @property {number} timeout
* Request timeout in millionseconds, by default it's 30000ms.
* Request timeout in millionseconds, by default it's 60000ms.
* @property {boolean} followRedirect
* Follow redirects automatically, default true
* @property {boolean} trusty
* Trust all certificates
* @property {boolean} wifiOnly
* Only do requests through WiFi. Android SDK 21 or above only.
*

@@ -110,0 +116,0 @@ * @return {function} This method returns a `fetch` method instance.

2

package.json
{
"name": "rn-fetch-blob",
"version": "0.11.2",
"version": "0.12.0",
"description": "A module provides upload, download, and files access API. Supports file stream read/write for process large files.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -44,3 +44,3 @@ # rn-fetch-blob

This project was started in the cause of solving issue [facebook/react-native#854](https://github.com/facebook/react-native/issues/854), React Native's lacks of `Blob` implementation which results into problems when transferring binary data.
This project was started in the cause of solving issue [facebook/react-native#854](https://github.com/facebook/react-native/issues/854), React Native's lacks of `Blob` implementation which results into problems when transferring binary data.

@@ -120,4 +120,4 @@ It is committed to making file access and transfer easier and more efficient for React Native developers. We've implemented highly customizable filesystem and network module which plays well together. For example, developers can upload and download data directly from/to storage, which is more efficient, especially for large files. The file system supports file stream, so you don't have to worry about OOM problem when accessing large files.

<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />

@@ -134,6 +134,14 @@ ...

<category android:name="android.intent.category.LAUNCHER" />
+ <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
+ <action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
```
If you are going to use the `wifiOnly` flag, you need to add this to `AndroidManifest.xml`
```diff
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
...
```
**Grant Access Permission for Android 6.0**

@@ -174,3 +182,3 @@

- To send binary data, you have two choices, use BASE64 encoded string or path points to a file contains the body.
- If the `Content-Type` containing substring`;BASE64` or `application/octet` the given body will be considered as a BASE64 encoded data which will be decoded to binary data as the request body.
- If the `Content-Type` containing substring`;BASE64` or `application/octet` the given body will be considered as a BASE64 encoded data which will be decoded to binary data as the request body.
- Otherwise, if a string starts with `RNFetchBlob-file://` (which can simply be done by `RNFetchBlob.wrap(PATH_TO_THE_FILE)`), it will try to find the data from the URI string after `RNFetchBlob-file://` and use it as the request body.

@@ -196,3 +204,3 @@ - To send the body as-is, simply use a `Content-Type` header not containing `;BASE64` or `application/octet`.

let status = res.info().status;
if(status == 200) {

@@ -298,3 +306,3 @@ // the conversion is done in native code

// (you can use "base64"(refer to the library 'mathiasbynens/base64') APIs to make one).
// The data will be converted to "byte array"(say, blob) before request sent.
// The data will be converted to "byte array"(say, blob) before request sent.
}, base64ImageString)

@@ -657,3 +665,3 @@ .then((res) => {

})
ifstream.onEnd(() => {
ifstream.onEnd(() => {
<Image source={{ uri : 'data:image/png,base64' + data }}

@@ -683,3 +691,3 @@ })

or
or

@@ -760,3 +768,3 @@ ```js

res.session('foo')
})
})

@@ -771,3 +779,3 @@ RNFetchblob.config({

// ...
})
})

@@ -807,2 +815,18 @@ // or put an existing file path to the session

### WiFi only requests
If you wish to only route requests through the Wifi interface, set the below configuration.
Note: On Android, the `ACCESS_NETWORK_STATE` permission must be set, and this flag will only work
on API version 21 (Lollipop, Android 5.0) or above. APIs below 21 will ignore this flag.
```js
RNFetchBlob.config({
wifiOnly : true
})
.fetch('GET', 'https://mysite.com')
.then((resp) => {
// ...
})
```
## Web API Polyfills

@@ -809,0 +833,0 @@

@@ -8,3 +8,6 @@

addAndroidDownloads : any,
indicator : bool
indicator : bool,
followRedirect : bool,
trusty : bool,
wifiOnly : bool
};

@@ -11,0 +14,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc