nbimg
image upload api
Last updated 3 months ago by yahtnif .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install nbimg 
SYNC missed versions from official npm registry.

Version License

Fork: upimg

Usage

Installation

npm install nbimg

or

yarn add nbimg

Require 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
sohu 搜狐 - cy-pic.kuaizhan.com
suning 苏宁易购 - image.suning.cn
toutiao 今日头条 - p.pstatp.com
uploadcc Upload.cc - upload.cc
vim vim-cn - img.vim-cn.com
xiaomi 小米有品 - shop.io.mi-img.com
imgur imgur clientid i.imgur.com
qcloud 云+社区 cookie ask.qcloudimg.com
weibo 微博 cookie wx1.sinaimg.cn

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"
  }
}

take qcloud for cookies required example

nbimg.qcloud
  .set('cookie', 'foo=bar; xxx=123')
  .upload('./test/1.jpg')
  .then(json => console.log(json))
  .catch(err => console.error(err.message))

success response

{
  "success": true,
  "message": "success",
  "url": "https://ask.qcloudimg.com/draft/1134330/g2oaa9bdbx.png",
  "type": {
    "ext": "png",
    "mime": "image/png"
  }
}

API

upimg[server]

Returns an class with function:

  • set(key, value) - set options
  • upload(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.

.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

image

Type: Buffer | string

Pass pathname or image content buffers

Current Tags

  • 0.5.0                                ...           latest (3 months ago)

8 Versions

  • 0.5.0                                ...           3 months ago
  • 0.4.0                                ...           3 months ago
  • 0.3.0                                ...           3 months ago
  • 0.2.1                                ...           3 months ago
  • 0.2.0                                ...           3 months ago
  • 0.1.2                                ...           3 months ago
  • 0.1.1                                ...           3 months ago
  • 0.1.0                                ...           3 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 8
Dependencies (5)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |