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

down-file

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

down-file

download file

  • 1.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Install

$ npm install down-file -S  或者 yarn add down-file

Usage

import downloadFile from 'down-file';

downloadFile('http://domain.asset.test.png','test.png',{
    progress(e){
        console.log(e)
    },
    success(e){
        console.log(e)
    },
    failed(e){
        console.log(e)
    },
    complete(e){
        console.log(e)
    }
},{token:'123'})

API

downloadFile(fileUrl,fileName,[options],headers)

fileUrl

Type: string

文件下载地址

fileName

Type: string

下载文件保存的名字,注意,需要带文件对应的扩展名 如果 .jpg .zip 等

options

Type: Object

progress

Type: function

文件下载的进度回调函数,参数是 ProgressEvent 类型,可以获取文件的总大小,和当前已下载的大小

注意 使用该方法需服务端设置响应头,文件的大小 Content-Length 属性, eg: ctx.set('Content-Length', file.size)

success

Type: function

文件下载成功的回调函数,参数是 ProgressEvent 类型

failed

Type: function

文件下载失败的回调函数,参数是 ProgressEvent 类型

complete

Type: function

文件下载无论成功还是失败回调函数,参数是 ProgressEvent 类型

headers

Type: object

http headers to post, available in modern browsers

FAQs

Package last updated on 22 Oct 2019

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