1.0.0 • Published 9 years ago
upyun.io v1.0.0
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 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
}, {
// ...
}]Example
const upyun = require('upyun.io')
const client = upyun({
bucket: '',
operator: '',
password: '',
endpoint: ''
})
await client.getUsage()
await client.listBucket('/')License
MIT