1.0.12 • Published 7 years ago

sugo-agent-file v1.0.12

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

sugo-agent-file

Build Status npm Version JS Standard

Client for sugo-endpoint-file

Installation

$ npm install sugo-agent-file --save

Usage

Use this agent to access a sg-server (or SUGO-Hub) which uses sugo-endpoint-file plugin.

'use strict'

const sugoAgentFile = require('sugo-agent-file')
const co = require('co')

co(function * () {
  let agent = sugoAgentFile('http://my-sever.com/files')

  // Check if server available
  {
    let ok = yield agent.knock() // Send HTTP HEAD request.
    /* ... */
  }

  // Access dynamic files
  {
    // Write
    yield agent.write('my-text-01.txt', 'This is the text.')
    // Read
    let content = yield agent.read('my-text-01.txt')
    console.log(content)
    /* ... */
    // Check
    let exists = yield agent.exists('my-text-01.text')
    if (exists) {
      // Delete
      yield agent.delete('my-text-01.txt')
    }
  }
}).catch((err) => console.error(err))

License

This software is released under the Apache-2.0 License.

Links