1.0.4 • Published 7 years ago

sugo-endpoint-zip v1.0.4

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
7 years ago

sugo-endpoint-zip

Build Status npm Version JS Standard

Endpoint to download files as zip

Requirements

Installation

$ npm install sugo-endpoint-zip --save

Usage

Create an instance and apply to sg-server (or sugo-cloud)

/** This is an example to use sugo-endpoint-zip */

'use strict'

const sgServer = require('sg-server')

const server = sgServer({
  middlewares: [
    /* ... */
  ],
  endpoints: {
    'download/:filename': require('sugo-endpoint-zip')({
      // Options
    })
  }
})

server.listen(3000)

Then call the api from agent script.

/** This is example of client */

'use strict'

const sugoAgentZip = require('sugo-agent-zip')
const co = require('co')

co(function * () {
  let agent = sugoAgentZip('/downloads')
  let knocked = yield agent.knock()
  /* .. */

  // Download the zip and save to file.
  yield agent.download('photos', 'tmp/downloads/photos.zip')
}).catch((err) => console.error(err))

Signature

sugoEndpointZip(options) -> function

Endpoint to download files as zip

Args
NameTypeDefaultDescription
optionsobjectOptional settings.

License

This software is released under the Apache-2.0 License.

Links