Socket
Socket
Sign inDemoInstall

rn-fetch-blob

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rn-fetch-blob

A module provides upload, download, and files access API. Supports file stream read/write for process large files.


Version published
Weekly downloads
111K
decreased by-7.13%
Maintainers
1
Weekly downloads
 
Created

What is rn-fetch-blob?

rn-fetch-blob is a popular npm package for React Native that provides a comprehensive set of tools for handling network requests, file system access, and data transfer. It allows developers to download and upload files, access the device's file system, and handle various types of data efficiently.

What are rn-fetch-blob's main functionalities?

File Download

This feature allows you to download files from a remote server and save them to the local file system. The code sample demonstrates how to download an image and save it with a .png extension.

const RNFetchBlob = require('rn-fetch-blob');

RNFetchBlob.config({
  fileCache: true,
  appendExt: 'png'
})
.fetch('GET', 'https://example.com/image.png')
.then((res) => {
  console.log('The file saved to ', res.path());
})
.catch((error) => console.error(error));

File Upload

This feature allows you to upload files to a remote server. The code sample demonstrates how to upload an image file using a POST request with multipart/form-data content type.

const RNFetchBlob = require('rn-fetch-blob');

RNFetchBlob.fetch('POST', 'https://example.com/upload', {
  'Content-Type': 'multipart/form-data'
}, [
  { name: 'file', filename: 'image.png', data: RNFetchBlob.wrap('/path/to/image.png') }
])
.then((res) => {
  console.log(res.text());
})
.catch((error) => console.error(error));

File System Access

This feature provides access to the device's file system, allowing you to read files. The code sample demonstrates how to read a text file and log its contents.

const RNFetchBlob = require('rn-fetch-blob');

RNFetchBlob.fs.readFile('/path/to/file.txt', 'utf8')
.then((data) => {
  console.log(data);
})
.catch((error) => console.error(error));

Data Streaming

This feature allows you to handle large data transfers efficiently by streaming data. The code sample demonstrates how to download a large file with progress updates.

const RNFetchBlob = require('rn-fetch-blob');

RNFetchBlob.fetch('GET', 'https://example.com/largefile.zip', {
  'Transfer-Encoding': 'chunked'
})
.progress((received, total) => {
  console.log('progress', received / total);
})
.then((res) => {
  console.log('The file saved to ', res.path());
})
.catch((error) => console.error(error));

Other packages similar to rn-fetch-blob

Keywords

FAQs

Package last updated on 14 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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