0.5.3 • Published 2 years ago

upimg v0.5.3

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

Usage

Installation

npm install upimg

or

yarn add upimg

Require module

const upimg = require('upimg')

Support servers

serverendpointauthurlstatus
5858 同城-pic3.58cdn.com.cn
alibabaaliexpress-ae01.alicdn.com
baidu百度百家号-pic.rmb.bdstatic.com
jd京东-img14.360buyimg.com
netease网易严选-yanxuan.nosdn.127.net失效
suning苏宁易购-image.suning.cn失效
toutiao今日头条-p.pstatp.com失效
xiaomi小米有品-shop.io.mi-img.com失效
xiaoyuzhou小宇宙-image.xyzcdn.net
xitu掘金-user-gold-cdn.xitu.io失效
bilibili哔哩哔哩cookiei0.hdslb.com
qcloud云+社区cookieask.qcloudimg.com
qiniu七牛云cookiedn-odum9helk.qbox.me
ximalaya喜马拉雅cookiefdfs.xmcdn.com

Upload file

take alibaba for example

upimg.alibaba
    .upload('./test/nodejs.png')
    .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

upimg.qcloud
    .set('cookie', 'foo=bar; xxx=123')
    .upload('./test/nodejs.png')
    .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

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.

.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

Author

upimg © metowolf, Released under the MIT License.

Blog @meto · GitHub @metowolf · Twitter @metowolf

0.5.3

2 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

4 years ago

0.4.4

4 years ago

0.5.0-rc.0

4 years ago

0.5.0-beta.2

4 years ago

0.5.0-beta.1

4 years ago

0.5.0-beta.0

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago