iojs client for upyun
Why not use official upyun sdk
- Promise based
- Use ES6+, need iojs@2+
- More friendly api
- More stable (error handling, no *Sync methods, ...)
-
getUsage()
-
listBucket(path, opts)
path
:{String}
upyun pathopts
:{Object}
TODO
-
putFile(source, path, opts)
source
:{String|Buffer|Stream}
file path, buffer data, file stream to uploadpath
:{String}
upyun pathopts
:{Object}
type
:Content-Type
, will parsed by jshttp/mime-typessize
: file size, note: if you put file by stream, size is requiredheaders
:{Object}
, custom http headers
-
headFile(path)
path
:{String}
upyun path
-
getFile(path, dest)
path
:{String}
upyun pathdest
:{String}
dest file path
-
rmFile(path)
path
:{String}
upyun path
-
result
status
: http response statusCodeheaders
: http response headersbody
: http response body (for most cases, it's''
)- for
listBucket
, the body isjson
, with the data below
- for
// body
[{
bucket: 'bucket name',
type: 'file',
size: 1024,
modifyTime: 1431583534
}, {
bucket: 'bucket name',
type: 'folder',
size: 1024,
modifyTime: 1431583534
}, {
// ...
}]
let upyun = require('upyun.io')
let client = upyun({
bucket: '',
operator: '',
password: '',
endpoint: ''
})
await client.getUsage()
await client.listBucket('/')
MIT