1.0.0 • Published 7 years ago

upyun.io v1.0.0

Weekly downloads
12
License
MIT
Repository
github
Last release
7 years ago

NPM version License Dependency status Node Version

upyun.io

another nodejs client for upyun

Why not use official upyun sdk

  • Promise based, async/await friendly
  • More friendly APIs
  • More stable (error handling, no *Sync methods, ...)

Some CLI tools

APIs

  • getUsage()

  • listBucket(path, opts)

    • path: {String} upyun path
    • opts: {Object} TODO
  • putFile(source, path, opts)

    • source: {String|Buffer|Stream} file path, buffer data, file stream to upload
    • path: {String} upyun path
    • opts: {Object}
      • type: Content-Type, will parsed by jshttp/mime-types
      • size: file size, note: if you put file by stream, size is required
      • headers: {Object}, custom http headers
  • headFile(path)

    • path: {String} upyun path
  • getFile(path, dest)

    • path: {String} upyun path
    • dest: {String} dest file path
  • rmFile(path)

    • path: {String} upyun path
  • result

    • status: http response statusCode
    • headers: http response headers
    • body: http response body (for most cases, it's '')
      • for listBucket, the body is json, with the data below
// body
[{
  bucket: 'bucket name',
  type: 'file',
  size: 1024,
  modifyTime: 1431583534
}, {
  bucket: 'bucket name',
  type: 'folder',
  size: 1024,
  modifyTime: 1431583534
}, {
  // ...
}]

Example

const upyun = require('upyun.io')
const client = upyun({
  bucket: '',
  operator: '',
  password: '',
  endpoint: ''
})

await client.getUsage()
await client.listBucket('/')

License

MIT