Giter Site home page Giter Site logo

web-downloadfile's Introduction

web-downloadfile

文件下载 web-downloadfile

BlogAddress

纯前端下载文件

Installation

  $ npm install web-downloadfile --save
  # or
  $ yarn add web-downloadfile

Usage

import { base64ToFileOrBlob, saveFileToBlob, saveFileToLink } from 'web-downloadfile';

一,base64ToFileOrBlob

主要针对图片 base64转blob对象 或 直接下载文件 但是文件也可用

  import { base64ToFileOrBlob } from 'web-downloadfile';

  let Blob = base64ToFileOrBlob(base64,'',true);

  // or

   base64ToFileOrBlob(base64,'',false);

二,saveFileToBlob

主要用于文件导出下载 支持大部分文件类型 但是文件类型必传

  import { saveFileToBlob } from 'web-downloadfile';

  saveFileToBlob(Blob,'test','xlsx');

三,saveFileToLink

主要pdf文件链接的下载 因为pdf文件链接在浏览器会直接打开 但是其他文件的链接也可以下载 可监听文件下载进度

link必须允许跨越访问 否则无法下载

  import { saveFileToLink } from 'web-downloadfile';

  saveFileToLink(link,'test','jpg',fn);

web-downloadfile's People

Contributors

jiang-jackson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.