ali-img
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -6,3 +6,4 @@ const fs = require('fs') | ||
const https = require('https') | ||
const { Transform, Readable } = require('stream') | ||
const Stream = require('stream') | ||
const { Transform, Readable } = Stream | ||
const fileType = require('file-type') | ||
@@ -12,3 +13,3 @@ | ||
const { getVal, compose } = require('./util') | ||
const { HTTPError } = require('./error') | ||
const { HTTPError, AliImgError } = require('./error') | ||
@@ -212,8 +213,12 @@ // 请求网络图片时使用的代理信息 | ||
let taskList = list.map(({ src, target }) => { | ||
if (src instanceof Readable) { | ||
if (src instanceof Stream) { | ||
return this.putObjectFromStream(src, target) | ||
} else if (/https?:\/\//i.test(src)) { | ||
return this.putObjectFromUrl(src, target) | ||
} else if (typeof src === 'string') { | ||
if (/https?:\/\//i.test(src)) { | ||
return this.putObjectFromUrl(src, target) | ||
} else { | ||
return this.putObject(src, target) | ||
} | ||
} else { | ||
return this.putObject(src, target) | ||
throw new AliImgError('不支持该类型') | ||
} | ||
@@ -220,0 +225,0 @@ }) |
{ | ||
"name": "ali-img", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "阿里云OSS图片处理工具", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
58472
963