New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-fetch-blob

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-fetch-blob - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2

ios/RNFetchBlobReqBuilder.h

13

fs.js

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

DeviceEventEmitter,
Platform,
NativeAppEventEmitter,

@@ -51,2 +52,11 @@ } from 'react-native'

function asset(path:string):string {
if(Platform.OS === 'ios') {
// path from camera roll
if(/^assets-library\:\/\//.test(path))
return path
}
return 'bundle-assets://' + path
}
function createFile(path:string, data:string, encoding: 'base64' | 'ascii' | 'utf8'):Promise {

@@ -329,3 +339,4 @@ encoding = encoding || 'utf8'

scanFile,
dirs
dirs,
asset
}

2

index.js

@@ -275,3 +275,3 @@ /**

fs,
wrap,
wrap
}
{
"name": "react-native-fetch-blob",
"version": "0.6.1",
"version": "0.6.2",
"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",

@@ -1,8 +0,10 @@

# react-native-fetch-blob [![npm](https://img.shields.io/npm/v/react-native-fetch-blob.svg?style=flat-square)](https://www.npmjs.com/package/react-native-fetch-blob) ![](https://img.shields.io/badge/PR-Welcome-brightgreen.svg?style=flat-square) [![npm](https://img.shields.io/npm/l/express.svg?maxAge=2592000&style=flat-square)]()
# react-native-fetch-blob [![npm](https://img.shields.io/npm/v/react-native-fetch-blob.svg?style=flat-square)](https://www.npmjs.com/package/react-native-fetch-blob) ![](https://img.shields.io/badge/PR-Welcome-brightgreen.svg?style=flat-square) [![npm](https://img.shields.io/npm/l/express.svg?maxAge=2592000&style=flat-square)]() [![npm](https://img.shields.io/badge/inProgress-0.7.0-yellow.svg?style=flat-square)](https://github.com/wkh237/react-native-fetch-blob/milestones)
A module provides upload, download, and files access API. Supports file stream read/write for process large files.
## [Please check our github for updated document](https://github.com/wkh237/react-native-fetch-blob)
**Why do we need this**
React Native does not support `Blob` object at this moment, which means if you're going to send/receive binary data via `fetch` API, that might not work as you expect. See [[fetch] Does fetch with blob() marshal data across the bridge?](https://github.com/facebook/react-native/issues/854).
React Native does not support `Blob` object at this moment, which means if you're going to send/receive binary data via `fetch` API, that might not work as you expect. See [facebook/react-native#854](https://github.com/facebook/react-native/issues/854).

@@ -13,5 +15,5 @@ For some use cases, you might get into trouble. For example, displaying an image that requires a specific field in headers (ex. "Authorization : Bearer ...") or body, so you can't just pass the image uri to `Image` component because that will probably returns a 401 response. Or you're going to upload binary data which generated from JS, the server will get an empry body due to [this issue](https://github.com/facebook/react-native/issues/854). With help of APIs provided by this module, you can send HTTP request with any headers, and decide how to handle the response/reqeust data without worry about if it is not supported by `fetch` API. The response data can be just simply converted into BASE64 string, or stored to a file directly so that you can read it by using file access APIs such as readFile, readStream.

**Pre v0.5.0 Users**
**Backward Compatible**
All updates are `backward-compatible` generally you don't have to change existing code unless you're going to use new APIs. In latest version (v0.5.0), new APIs can either `upload` or `download` files simply using a file path. It's much more memory efficent in some use case. We've also introduced `fs` APIs for access files, and `file stream` API that helps you read/write files (especially for **large ones**), see [Examples](#user-content-usage) bellow. This module implements native methods, supports both Android (uses awesome native library [AsyncHttpClient](https://github.com/AsyncHttpClient/async-http-client])) and IOS.
All updates are `backward-compatible` generally you don't have to change existing code unless you're going to use new APIs. But we recommend pre `0.5.0` users consider upgrade the package to latest version, since we have introduced new APIs can either `upload` or `download` files simply using a file path. It's much more memory efficent in some use case. We've also introduced `fs` APIs for access files, and `file stream` API that helps you read/write files (especially for **large ones**), see [Examples](#user-content-recipes) bellow. This module implements native methods, supports both Android (uses awesome native library [AsyncHttpClient](https://github.com/AsyncHttpClient/async-http-client])) and IOS.

@@ -21,3 +23,3 @@ ## TOC

* [Installation](#user-content-installation)
* [Guide](#user-content-guide)
* [Recipes](#user-content-recipes)
* [Download file](#user-content-download-example--fetch-files-that-needs-authorization-token)

@@ -84,3 +86,3 @@ * [Upload file](#user-content-upload-example--dropbox-files-upload-api)

## Guide
## Recipes

@@ -262,3 +264,3 @@ ```js

What if you want to upload a file in some field ? Just like [upload a file from storage](#user-content-upload-a-file-from-storage) example, wrap `data` by `wrap` API (this feature is only available for `version >= v0.5.0`)
What if you want to upload a file in some field ? Just like [upload a file from storage](#user-content-upload-a-file-from-storage) example, wrap `data` by `wrap` API (this feature is only available for `version >= v0.5.0`). On version >= `0.6.2`, it is possible to set custom MIME type when appending file to form data.

@@ -281,2 +283,10 @@ ```js

},
{
name : 'ringtone',
filename : 'ring.mp3',
// use custom MIME type
type : 'application/mp3',
// upload a file from asset is also possible in version >= 0.6.2
data : RNFetchBlob.wrap(RNFetchBlob.fs.asset('default-ringtone.mp3'))
}
// elements without property `filename` will be sent as plain text

@@ -297,3 +307,3 @@ { name : 'name', data : 'user'},

In `version >= 0.4.2` it is possible to know the upload/download progress.
In `version >= 0.4.2` it is possible to know the upload/download progress. On Anroid, only download progress is supported. See [wiki](https://github.com/wkh237/react-native-fetch-blob/wiki/Fetch-API#fetchprogresseventlistenerpromisernfetchblobresponse) for more information.

@@ -400,6 +410,8 @@ ```js

File access APIs were made when developing `v0.5.0`, which helping us write tests, and was not planned to be a part of this module. However I realized that, it's hard to find a great solution to manage cached files, every one who use this moudle may need those APIs for there cases.
File access APIs were made when developing `v0.5.0`, which helping us write tests, and was not planned to be a part of this module. However we realized that, it's hard to find a great solution to manage cached files, every one who use this moudle may need these APIs for there cases.
Before get started using file APIs we recommend read [Differences between File Source](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#differences-between-file-source) first.
File Access APIs
- [asset (0.6.2)](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#assetfilenamestringstring)
- [dirs](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#dirs)

@@ -433,3 +445,3 @@ - [createFile](https://github.com/wkh237/react-native-fetch-blob/wiki/File-System-Access-API#createfilepath-data-encodingpromise)

let data = ''
RNFetchBlob.readStream(
RNFetchBlob.fs.readStream(
// encoding, should be one of `base64`, `utf8`, `ascii`

@@ -461,3 +473,3 @@ 'base64',

```js
RNFetchBlob.writeStream(
RNFetchBlob.fs.writeStream(
PATH_TO_FILE,

@@ -551,2 +563,3 @@ // encoding, should be one of `base64`, `utf8`, `ascii`

|---|---|
| 0.6.2 | Add support of asset file and camera roll files, Support custom MIME type when sending multipart request, thanks @smartt |
| 0.6.1 | Fix #37 progress report API issue on IOS |

@@ -553,0 +566,0 @@ | 0.6.0 | Add readFile and writeFile API for easier file access, also added Android download manager support. |

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc