Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-blob-util

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-blob-util

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

  • 0.19.11
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
232K
increased by1.71%
Maintainers
1
Weekly downloads
 
Created

What is react-native-blob-util?

react-native-blob-util is a library for React Native that provides a comprehensive set of utilities for handling binary data, file system operations, and network requests. It is particularly useful for tasks such as downloading and uploading files, manipulating local files, and handling large data transfers.

What are react-native-blob-util's main functionalities?

File Download

This feature allows you to download files from a remote server and save them locally. The example demonstrates downloading an image and saving it with a .png extension.

const RNFetchBlob = require('react-native-blob-util');

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 example demonstrates uploading an image file using a POST request with multipart/form-data content type.

const RNFetchBlob = require('react-native-blob-util');

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

File System Operations

This feature allows you to perform file system operations such as reading files. The example demonstrates reading a text file and logging its contents.

const RNFetchBlob = require('react-native-blob-util');

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

Handling Large Data

This feature allows you to handle large data transfers efficiently. The example demonstrates downloading a large file and tracking the progress of the download.

const RNFetchBlob = require('react-native-blob-util');

RNFetchBlob.fetch('GET', 'https://example.com/largefile.zip', {
  'Cache-Control': 'no-store'
})
.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 react-native-blob-util

Keywords

FAQs

Package last updated on 22 Jul 2024

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