sugo-endpoint-zip
v1.0.4
Published
Endpoint to download files as zip
Downloads
2
Readme
sugo-endpoint-zip
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
| Name | Type | Default | Description | | --- | ---- | --- | --- | | options | object | | Optional settings. |
License
This software is released under the Apache-2.0 License.