Socket
Socket
Sign inDemoInstall

web-downloadfile

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-downloadfile

File saving and picture conversion,forked from https://github.com/jiang-jackson/web-downloadfile


Version published
Maintainers
1
Weekly downloads
39
increased by129.41%

Weekly downloads

Readme

Source

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');

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

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

  import { saveFileToLink } from 'web-downloadfile';

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

Keywords

FAQs

Last updated on 06 Dec 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc