mohcinenazrhan / file-downloader

File downloader for any web-based project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

file-downloader

File downloader for any web-based project. NPM JavaScript Style Guide

Install

npm install @mohcinenazrhan/file-downloader@1.0.1

See Example

Usage

downloadFileDisposition

This function will donwload the file using the disposition header to get the file name and extension.

function downloadFileDisposition(data: Blob, disposition: string, fallbackFileName: string): string;

import downloadFileDisposition from 'file-downloader';

const disposition = response.request.getResponseHeader('Content-Disposition');

if (disposition) {
  downloadFileDisposition(response.data, disposition, 'file.pdf');
} else {
  throw new Error('Content-Disposition header is missing');
}

downloadFile

This function will donwload the file.

function downloadFile(data: Blob, fileName: string): string;

import { downloadFile } from 'file-downloader';

downloadFile(blob, 'file.pdf');

Built with

  • TypeScript

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

File downloader for any web-based project

License:MIT License


Languages

Language:TypeScript 40.7%Language:JavaScript 34.6%Language:HTML 16.0%Language:CSS 8.7%