0.5.2 • Published 5 years ago

nbimg v0.5.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Fork: upimg

Usage

Installation

npm install nbimg

or

yarn add nbimg

Require module

const nbimg = require('nbimg')

Support servers

serverendpointauthurl
alibabaaliexpressae01.alicdn.comae01.alicdn.com
baidu百度百家号pic.rmb.bdstatic.compic.rmb.bdstatic.com
jd京东img14.360buyimg.comimg14.360buyimg.com
netease网易严选yanxuan.nosdn.127.netyanxuan.nosdn.127.net
smmssmmsi.loli.neti.loli.net
suning苏宁易购image.suning.cnimage.suning.cn
toutiao今日头条p.pstatp.comp.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 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.

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

image

Type: Buffer | string

Pass pathname or image content buffers

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago