rn-file-downloader
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

react-native-file-downloader

Boring to try to use rn-fetch-blob or the fork react-native-fetch-blob or another fork

This module provide a simple way to download file from API to Download (Android) / Documents(iOS)

npm downloads platform - android platform - ios

Installation

$ yarn add rn-file-downloader

Permissions

Android

Add this permissions in AndroidManifest.xml

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

iOS

Add this permissions in Info.plist

<key>UIFileSharingEnabled</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>

Usage

Methods

Name Description Arguments Return value
downloadFile Download a file in Download/Document url: string, filename: string, headers: stringify storePath: string

Sample

import { downloadFile } from "rn-file-downloader";

//...

downloadFile(
        'https://picsum.photos/200/300',
        'my-picture.jpg',
        JSON.stringify({
            Authorization: 'Bearer ' + accessToken,
        })
    )
    .then((path: string) => {
        //...
    })
    .catch((error: string) => {
        //...
    });

Package Sidebar

Install

npm i rn-file-downloader

Weekly Downloads

1

Version

2.0.1

License

MIT

Unpacked Size

1.67 MB

Total Files

226

Last publish

Collaborators

  • 0mnilog