siwi-file

1.0.3 • Public • Published

Build Status npm npm Github file size

siwi-file

file download for nodejs

install

use npm

npm install siwi-file

use yarn

yarn add siwi-file

Example

code example download nodejs pkg

(async () => {
    const path = require('path')
    const { file }  = require('./index')
    const url = 'https://nodejs.org/dist/v11.11.0/node-v11.11.0.pkg'
    const savepath = path.resolve('./storage', 'node-v11.11.0.pkg')
    try {
        await file(url, savepath)
        console.log('下载完成');
    } catch (error) {
        console.trace(error)
    }
})()

run node test.js

node test.js

siwi-file-demo

Test

npm test

const expect = require('chai').expect
describe('siwi-file.js', () => {
    it('file', async () => {
        const { file } = require('../lib')
        const fs = require('fs')
        const path = require('path')
        const url = 'https://mac-torrent-download.net/wp-content/uploads/tr-files/2019-q1/50c621b678278d22e81056cbb9827694.torrent'
        const basename = path.basename(url)
        const savepath = path.resolve('./storage/torrents', `${basename}`)
        await file(url, savepath)
        const res = fs.existsSync(savepath)
        expect(res).to.be.equal(true)
    });
});

Package Sidebar

Install

npm i siwi-file

Weekly Downloads

5

Version

1.0.3

License

MIT

Unpacked Size

1.11 MB

Total Files

10

Last publish

Collaborators

  • siwi