项目作者: realglobe-Inc

项目描述 :
Client for sugo-endpoint-file
高级语言: JavaScript
项目地址: git://github.com/realglobe-Inc/sugo-agent-file.git
创建时间: 2016-06-29T09:04:22Z
项目社区:https://github.com/realglobe-Inc/sugo-agent-file

开源协议:Apache License 2.0

下载


sugo-agent-file

Build Status
npm Version
JS Standard

Client for sugo-endpoint-file

Installation

  1. $ npm install sugo-agent-file --save

Usage

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

  1. 'use strict'
  2. const sugoAgentFile = require('sugo-agent-file')
  3. const co = require('co')
  4. co(function * () {
  5. let agent = sugoAgentFile('http://my-sever.com/files')
  6. // Check if server available
  7. {
  8. let ok = yield agent.knock() // Send HTTP HEAD request.
  9. /* ... */
  10. }
  11. // Access dynamic files
  12. {
  13. // Write
  14. yield agent.write('my-text-01.txt', 'This is the text.')
  15. // Read
  16. let content = yield agent.read('my-text-01.txt')
  17. console.log(content)
  18. /* ... */
  19. // Check
  20. let exists = yield agent.exists('my-text-01.text')
  21. if (exists) {
  22. // Delete
  23. yield agent.delete('my-text-01.txt')
  24. }
  25. }
  26. }).catch((err) => console.error(err))

License

This software is released under the Apache-2.0 License.