0.5.2 • Published 6 years ago
nbimg v0.5.2
Fork: upimg
Usage
Installation
npm install nbimgor
yarn add nbimgRequire module
const nbimg = require('nbimg')Support servers
| server | endpoint | auth | url |
|---|---|---|---|
| alibaba | aliexpress | ae01.alicdn.com | ![]() |
| baidu | 百度百家号 | pic.rmb.bdstatic.com | ![]() |
| jd | 京东 | img14.360buyimg.com | ![]() |
| netease | 网易严选 | yanxuan.nosdn.127.net | ![]() |
| smms | smms | i.loli.net | ![]() |
| suning | 苏宁易购 | image.suning.cn | ![]() |
| toutiao | 今日头条 | p.pstatp.com |
Upload file
take alibaba for example
nbimg.alibaba
.upload('./test/1.jpg')
.then(json => console.log(json))
.catch(err => console.error(err.message))success response
{
"success": true,
"message": "success",
"url": "https://ae01.alicdn.com/kf/HTB1dYeZXZrrK1RjSspa763REXXaP.png",
"type": {
"ext": "png",
"mime": "image/png"
}
}API
upimgserver
Returns an class with function:
set(key, value)- set optionsupload(image)- upload image
Or undefined when there is no server match.
.set(key, value)
Sets options[key] to value.
Returns a Promise which resolves self.
nbimg.xxx
.set('cookie', 'foo=bar; xxx=123')
.upload('./test/1.jpg')
.then(json => console.log(json))
.catch(err => console.error(err.message)).upload(image)
Upload image to CDN server.
Returns a Promise which resolves upload result.
- success:
boolean - message:
string - url:
string(url) - type:
object- ext:
string - mime:
string
- ext:
image
Type: Buffer | string
Pass pathname or image content buffers





