From 174d1109952dc8af1f782d3ad3263cb4bc1a9f52 Mon Sep 17 00:00:00 2001 From: taevas Date: Mon, 15 Jul 2019 09:52:27 +0800 Subject: [PATCH] 3.3.10 --- dist/upyun.common.js | 35 +++++++++++++++++++---------------- dist/upyun.esm.js | 4 ++-- dist/upyun.js | 4 ++-- dist/upyun.min.js | 4 ++-- package.json | 2 +- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/dist/upyun.common.js b/dist/upyun.common.js index bfee622..063ab59 100644 --- a/dist/upyun.common.js +++ b/dist/upyun.common.js @@ -1,5 +1,5 @@ /** - * UPYUN js-sdk 3.3.9 + * UPYUN js-sdk 3.3.10 * (c) 2019 * @license MIT */ @@ -13,6 +13,7 @@ var url = _interopDefault(require('url')); var fs = _interopDefault(require('fs')); var mime = _interopDefault(require('mime-types')); var FormData = _interopDefault(require('form-data')); +var path = _interopDefault(require('path')); var hmacsha1 = _interopDefault(require('hmacsha1')); var base64 = _interopDefault(require('base-64')); var md5 = _interopDefault(require('md5')); @@ -48,13 +49,13 @@ var createReq = function (endpoint, service, getHeaderSign) { req.interceptors.request.use(function (config) { var method = config.method.toUpperCase(); - var path = url.resolve('/', config.url || ''); + var path$$1 = url.resolve('/', config.url || ''); - if (path.indexOf(config.baseURL) === 0) { - path = path.substring(config.baseURL.length); + if (path$$1.indexOf(config.baseURL) === 0) { + path$$1 = path$$1.substring(config.baseURL.length); } config.url = encodeURI(config.url); - var headerSign = getHeaderSign(service, method, path, config.headers['Content-MD5']); + var headerSign = getHeaderSign(service, method, path$$1, config.headers['Content-MD5']); headerSign = isPromise(headerSign) ? headerSign : Promise.resolve(headerSign); return headerSign.then(function (headers) { @@ -144,8 +145,10 @@ function formUpload(remoteUrl, localFile, _ref) { // NOTE when type of localFile is buffer/string, // force set filename=file, FormData will treat it as a file // real filename will be set by save-key in policy + var filename = localFile.name || localFile.path ? path.basename(localFile.name || localFile.path) : 'file'; + data.append('file', localFile, { - filename: 'file' + filename: filename }); data.submit(remoteUrl, function (err, res) { if (err) { @@ -178,7 +181,7 @@ function formUpload(remoteUrl, localFile, _ref) { } var name = "upyun"; -var version = "3.3.9"; +var version = "3.3.10"; var description = "UPYUN js sdk"; var main = "dist/upyun.common.js"; var module$1 = "dist/upyun.esm.js"; @@ -220,14 +223,14 @@ var pkg = { * @param {string} path - storage path on upyun server, e.g: /your/dir/example.txt * @param {string} contentMd5 - md5 of the file that will be uploaded */ -function getHeaderSign(service, method, path) { +function getHeaderSign(service, method, path$$1) { var contentMd5 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; var date = new Date().toGMTString(); - path = '/' + service.serviceName + path; + path$$1 = '/' + service.serviceName + path$$1; var sign = genSign(service, { method: method, - path: path, + path: path$$1, date: date, contentMd5: contentMd5 }); @@ -244,10 +247,10 @@ function getHeaderSign(service, method, path) { */ function genSign(service, options) { var method = options.method, - path = options.path; + path$$1 = options.path; - var data = [method, encodeURI(path)]; + var data = [method, encodeURI(path$$1)]; // optional params ['date', 'policy', 'contentMd5'].forEach(function (item) { @@ -473,9 +476,9 @@ var Upyun = function () { }, { key: 'usage', value: function usage() { - var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/'; + var path$$1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/'; - return this.req.get(path + '?usage').then(function (_ref) { + return this.req.get(path$$1 + '?usage').then(function (_ref) { var data = _ref.data; return Promise.resolve(data); @@ -484,7 +487,7 @@ var Upyun = function () { }, { key: 'listDir', value: function listDir() { - var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/'; + var path$$1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/'; var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, _ref2$limit = _ref2.limit, @@ -509,7 +512,7 @@ var Upyun = function () { requestHeaders['x-list-iter'] = iter; } - return this.req.get(path, { + return this.req.get(path$$1, { headers: requestHeaders }).then(function (_ref3) { var data = _ref3.data, diff --git a/dist/upyun.esm.js b/dist/upyun.esm.js index 5e8a5d2..64f4cd9 100644 --- a/dist/upyun.esm.js +++ b/dist/upyun.esm.js @@ -1,5 +1,5 @@ /** - * UPYUN js-sdk 3.3.9 + * UPYUN js-sdk 3.3.10 * (c) 2019 * @license MIT */ @@ -1737,7 +1737,7 @@ var base64 = createCommonjsModule(function (module, exports) { }); var name = "upyun"; -var version = "3.3.9"; +var version = "3.3.10"; var description = "UPYUN js sdk"; var main = "dist/upyun.common.js"; var module$1 = "dist/upyun.esm.js"; diff --git a/dist/upyun.js b/dist/upyun.js index 7120e0b..edf33a2 100644 --- a/dist/upyun.js +++ b/dist/upyun.js @@ -1,5 +1,5 @@ /** - * UPYUN js-sdk 3.3.9 + * UPYUN js-sdk 3.3.10 * (c) 2019 * @license MIT */ @@ -1743,7 +1743,7 @@ var base64 = createCommonjsModule(function (module, exports) { }); var name = "upyun"; -var version = "3.3.9"; +var version = "3.3.10"; var description = "UPYUN js sdk"; var main = "dist/upyun.common.js"; var module$1 = "dist/upyun.esm.js"; diff --git a/dist/upyun.min.js b/dist/upyun.min.js index 26344b1..96a5593 100644 --- a/dist/upyun.min.js +++ b/dist/upyun.min.js @@ -1,6 +1,6 @@ /** - * UPYUN js-sdk 3.3.9 + * UPYUN js-sdk 3.3.10 * (c) 2019 * @license MIT */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("axios")):"function"==typeof define&&define.amd?define(["axios"],e):t.upyun=e(t.axios)}(this,function(f){"use strict";f="default"in f?f.default:f;var s="undefined"!=typeof window&&("undefined"==typeof process||"browser"===process.title),u=1048576,p=function(t){return!!t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then};var E="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(t,e){return t(e={exports:{}},e.exports),e.exports}var N=t(function(T,U){!function(t){var e=U&&!U.nodeType&&U,r=T&&!T.nodeType&&T,n="object"==typeof E&&E;n.global!==n&&n.window!==n&&n.self!==n||(t=n);var o,i,m=2147483647,g=36,b=1,x=26,a=38,s=700,w=72,A=128,C="-",u=/^xn--/,h=/[^\x20-\x7E]/,l=/[\x2E\u3002\uFF0E\uFF61]/g,c={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},f=g-b,k=Math.floor,S=String.fromCharCode;function j(t){throw RangeError(c[t])}function p(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function v(t,e){var r=t.split("@"),n="";return 1>>10&1023|55296),t=56320|1023&t),e+=S(t)}).join("")}function q(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function I(t,e,r){var n=0;for(t=r?k(t/s):t>>1,t+=k(t/e);f*x>>1k((m-v)/a))&&j("overflow"),v+=u*a,!(u<(h=s<=y?b:y+x<=s?x:s-y));s+=g)a>k(m/(l=g-h))&&j("overflow"),a*=l;y=I(v-i,e=f.length+1,0==i),k(v/e)>m-d&&j("overflow"),d+=k(v/e),v%=e,f.splice(v++,0,d)}return P(f)}function y(t){var e,r,n,o,i,a,s,u,h,l,c,f,p,v,d,y=[];for(f=(t=O(t)).length,e=A,i=w,a=r=0;ak((m-r)/(p=n+1))&&j("overflow"),r+=(s-e)*p,e=s,a=0;am&&j("overflow"),c==e){for(u=r,h=g;!(u<(l=h<=i?b:i+x<=h?x:h-i));h+=g)d=u-l,v=g-l,y.push(S(q(l+d%v,0))),u=k(d/v);y.push(S(q(u,0))),i=I(r,p,n==o),r=0,++n}++r,++e}return y.join("")}if(o={version:"1.3.2",ucs2:{decode:O,encode:P},decode:d,encode:y,toASCII:function(t){return v(t,function(t){return h.test(t)?"xn--"+y(t):t})},toUnicode:function(t){return v(t,function(t){return u.test(t)?d(t.slice(4).toLowerCase()):t})}},e&&r)if(T.exports==e)r.exports=o;else for(i in o)o.hasOwnProperty(i)&&(e[i]=o[i]);else t.punycode=o}(E)}),B={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}};function r(t,e,r,n){e=e||"&",r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var i=/\+/g;t=t.split(e);var a=1e3;n&&"number"==typeof n.maxKeys&&(a=n.maxKeys);var s,u,h=t.length;0",'"',"`"," ","\r","\n","\t"]),F=["'"].concat(v),_=["%","/","?",";","#"].concat(F),L=["/","?","#"],D=/^[+a-z0-9A-Z_-]{0,63}$/,H=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Z={javascript:!0,"javascript:":!0},G={javascript:!0,"javascript:":!0},J={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function d(t,e,r){if(t&&B.isObject(t)&&t instanceof O)return t;var n=new O;return n.parse(t,e,r),n}O.prototype.parse=function(t,e,r){if(!B.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t.indexOf("?"),o=-1!==n&&n>16)+(e>>16)+(r>>16)<<16|65535&r}function A(t,e){return t<>>32-e}function u(t,e){t[e>>5]|=128<<24-e%32,t[15+(e+64>>9<<4)]=e;for(var r,n,o,i,a,s=[80],u=1732584193,h=-271733879,l=-1732584194,c=271733878,f=-1009589776,p=0;p>5]|=(t.charCodeAt(n/8)&r)<<32-s-n%32;return e}return i||(i="="),s||(s=8),function(t){for(var e="",r=0;r<4*t.length;r+=3)for(var n=(t[r>>2]>>8*(3-r%4)&255)<<16|(t[r+1>>2]>>8*(3-(r+1)%4)&255)<<8|t[r+2>>2]>>8*(3-(r+2)%4)&255,o=0;o<4;o++)8*r+6*o>32*t.length?e+=i:e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>6*(3-o)&63);return e}(function(t,e){var r=h(t);16>18&63)+l.charAt(o>>12&63)+l.charAt(o>>6&63)+l.charAt(63&o);return 2==i?(e=t.charCodeAt(s)<<8,r=t.charCodeAt(++s),a+=l.charAt((o=e+r)>>10)+l.charAt(o>>4&63)+l.charAt(o<<2&63)+"="):1==i&&(o=t.charCodeAt(s),a+=l.charAt(o>>2)+l.charAt(o<<4&63)+"=="),a},decode:function(t){var e=(t=String(t).replace(s,"")).length;e%4==0&&(e=(t=t.replace(/==?$/,"")).length),e%4!=1&&!/[^+a-zA-Z0-9/]/.test(t)||h("Invalid character: the string to be decoded is not correctly encoded.");for(var r,n,o=0,i="",a=-1;++a>(-2*o&6)));return i},version:"0.1.0"};if(e&&!e.nodeType)if(r)r.exports=i;else for(var a in i)i.hasOwnProperty(a)&&(e[a]=i[a]);else t.base64=i}(E)}),w="3.3.9",C=t(function(t){var i,r;i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={rotl:function(t,e){return t<>>32-e},rotr:function(t,e){return t<<32-e|t>>>e},endian:function(t){if(t.constructor==Number)return 16711935&r.rotl(t,8)|4278255360&r.rotl(t,24);for(var e=0;e>>5]|=t[r]<<24-n%32;return e},wordsToBytes:function(t){for(var e=[],r=0;r<32*t.length;r+=8)e.push(t[r>>>5]>>>24-r%32&255);return e},bytesToHex:function(t){for(var e=[],r=0;r>>4).toString(16)),e.push((15&t[r]).toString(16));return e.join("")},hexToBytes:function(t){for(var e=[],r=0;r>>6*(3-o)&63)):e.push("=");return e.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var e=[],r=0,n=0;r>>6-2*n);return e}},t.exports=r}),k={utf8:{stringToBytes:function(t){return k.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(k.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var e=[],r=0;r>>24)|4278255360&(r[u]<<24|r[u]>>>8);r[n>>>5]|=128<>>9<<4)]=n;var h=w._ff,l=w._gg,c=w._hh,f=w._ii;for(u=0;u>>0,i=i+v>>>0,a=a+d>>>0,s=s+y>>>0}return m.endian([o,i,a,s])})._ff=function(t,e,r,n,o,i,a){var s=t+(e&r|~e&n)+(o>>>0)+a;return(s<>>32-i)+e},w._gg=function(t,e,r,n,o,i,a){var s=t+(e&n|r&~n)+(o>>>0)+a;return(s<>>32-i)+e},w._hh=function(t,e,r,n,o,i,a){var s=t+(e^r^n)+(o>>>0)+a;return(s<>>32-i)+e},w._ii=function(t,e,r,n,o,i,a){var s=t+(r^(e|~n))+(o>>>0)+a;return(s<>>32-i)+e},w._blocksize=16,w._digestsize=16,t.exports=function(t,e){if(null==t)throw new Error("Illegal argument "+t);var r=m.wordsToBytes(w(t,e));return e&&e.asBytes?r:e&&e.asString?x.bytesToString(r):m.bytesToHex(r)}});function q(t,e){var r=e.method,n=e.path,o=[r,encodeURI(n)];["date","policy","contentMd5"].forEach(function(t){e[t]&&o.push(e[t])});var i=b(t.password,o.join("&"));return"UPYUN "+t.operatorName+":"+i}function I(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var T={genSign:q,getHeaderSign:function(t,e,r){var n=3= 0x80 (not a basic code point)","invalid-input":"Invalid input"},f=g-b,k=Math.floor,S=String.fromCharCode;function j(t){throw RangeError(c[t])}function p(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function v(t,e){var r=t.split("@"),n="";return 1>>10&1023|55296),t=56320|1023&t),e+=S(t)}).join("")}function q(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function I(t,e,r){var n=0;for(t=r?k(t/s):t>>1,t+=k(t/e);f*x>>1k((m-v)/a))&&j("overflow"),v+=u*a,!(u<(h=s<=y?b:y+x<=s?x:s-y));s+=g)a>k(m/(l=g-h))&&j("overflow"),a*=l;y=I(v-i,e=f.length+1,0==i),k(v/e)>m-d&&j("overflow"),d+=k(v/e),v%=e,f.splice(v++,0,d)}return P(f)}function y(t){var e,r,n,o,i,a,s,u,h,l,c,f,p,v,d,y=[];for(f=(t=O(t)).length,e=A,i=w,a=r=0;ak((m-r)/(p=n+1))&&j("overflow"),r+=(s-e)*p,e=s,a=0;am&&j("overflow"),c==e){for(u=r,h=g;!(u<(l=h<=i?b:i+x<=h?x:h-i));h+=g)d=u-l,v=g-l,y.push(S(q(l+d%v,0))),u=k(d/v);y.push(S(q(u,0))),i=I(r,p,n==o),r=0,++n}++r,++e}return y.join("")}if(o={version:"1.3.2",ucs2:{decode:O,encode:P},decode:d,encode:y,toASCII:function(t){return v(t,function(t){return h.test(t)?"xn--"+y(t):t})},toUnicode:function(t){return v(t,function(t){return u.test(t)?d(t.slice(4).toLowerCase()):t})}},e&&r)if(T.exports==e)r.exports=o;else for(i in o)o.hasOwnProperty(i)&&(e[i]=o[i]);else t.punycode=o}(E)}),B={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}};function r(t,e,r,n){e=e||"&",r=r||"=";var o={};if("string"!=typeof t||0===t.length)return o;var i=/\+/g;t=t.split(e);var a=1e3;n&&"number"==typeof n.maxKeys&&(a=n.maxKeys);var s,u,h=t.length;0",'"',"`"," ","\r","\n","\t"]),F=["'"].concat(v),_=["%","/","?",";","#"].concat(F),L=["/","?","#"],D=/^[+a-z0-9A-Z_-]{0,63}$/,H=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Z={javascript:!0,"javascript:":!0},G={javascript:!0,"javascript:":!0},J={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function d(t,e,r){if(t&&B.isObject(t)&&t instanceof O)return t;var n=new O;return n.parse(t,e,r),n}O.prototype.parse=function(t,e,r){if(!B.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t.indexOf("?"),o=-1!==n&&n>16)+(e>>16)+(r>>16)<<16|65535&r}function A(t,e){return t<>>32-e}function u(t,e){t[e>>5]|=128<<24-e%32,t[15+(e+64>>9<<4)]=e;for(var r,n,o,i,a,s=[80],u=1732584193,h=-271733879,l=-1732584194,c=271733878,f=-1009589776,p=0;p>5]|=(t.charCodeAt(n/8)&r)<<32-s-n%32;return e}return i||(i="="),s||(s=8),function(t){for(var e="",r=0;r<4*t.length;r+=3)for(var n=(t[r>>2]>>8*(3-r%4)&255)<<16|(t[r+1>>2]>>8*(3-(r+1)%4)&255)<<8|t[r+2>>2]>>8*(3-(r+2)%4)&255,o=0;o<4;o++)8*r+6*o>32*t.length?e+=i:e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(n>>6*(3-o)&63);return e}(function(t,e){var r=h(t);16>18&63)+l.charAt(o>>12&63)+l.charAt(o>>6&63)+l.charAt(63&o);return 2==i?(e=t.charCodeAt(s)<<8,r=t.charCodeAt(++s),a+=l.charAt((o=e+r)>>10)+l.charAt(o>>4&63)+l.charAt(o<<2&63)+"="):1==i&&(o=t.charCodeAt(s),a+=l.charAt(o>>2)+l.charAt(o<<4&63)+"=="),a},decode:function(t){var e=(t=String(t).replace(s,"")).length;e%4==0&&(e=(t=t.replace(/==?$/,"")).length),e%4!=1&&!/[^+a-zA-Z0-9/]/.test(t)||h("Invalid character: the string to be decoded is not correctly encoded.");for(var r,n,o=0,i="",a=-1;++a>(-2*o&6)));return i},version:"0.1.0"};if(e&&!e.nodeType)if(r)r.exports=i;else for(var a in i)i.hasOwnProperty(a)&&(e[a]=i[a]);else t.base64=i}(E)}),w="3.3.10",C=t(function(t){var i,r;i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={rotl:function(t,e){return t<>>32-e},rotr:function(t,e){return t<<32-e|t>>>e},endian:function(t){if(t.constructor==Number)return 16711935&r.rotl(t,8)|4278255360&r.rotl(t,24);for(var e=0;e>>5]|=t[r]<<24-n%32;return e},wordsToBytes:function(t){for(var e=[],r=0;r<32*t.length;r+=8)e.push(t[r>>>5]>>>24-r%32&255);return e},bytesToHex:function(t){for(var e=[],r=0;r>>4).toString(16)),e.push((15&t[r]).toString(16));return e.join("")},hexToBytes:function(t){for(var e=[],r=0;r>>6*(3-o)&63)):e.push("=");return e.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var e=[],r=0,n=0;r>>6-2*n);return e}},t.exports=r}),k={utf8:{stringToBytes:function(t){return k.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(k.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var e=[],r=0;r>>24)|4278255360&(r[u]<<24|r[u]>>>8);r[n>>>5]|=128<>>9<<4)]=n;var h=w._ff,l=w._gg,c=w._hh,f=w._ii;for(u=0;u>>0,i=i+v>>>0,a=a+d>>>0,s=s+y>>>0}return m.endian([o,i,a,s])})._ff=function(t,e,r,n,o,i,a){var s=t+(e&r|~e&n)+(o>>>0)+a;return(s<>>32-i)+e},w._gg=function(t,e,r,n,o,i,a){var s=t+(e&n|r&~n)+(o>>>0)+a;return(s<>>32-i)+e},w._hh=function(t,e,r,n,o,i,a){var s=t+(e^r^n)+(o>>>0)+a;return(s<>>32-i)+e},w._ii=function(t,e,r,n,o,i,a){var s=t+(r^(e|~n))+(o>>>0)+a;return(s<>>32-i)+e},w._blocksize=16,w._digestsize=16,t.exports=function(t,e){if(null==t)throw new Error("Illegal argument "+t);var r=m.wordsToBytes(w(t,e));return e&&e.asBytes?r:e&&e.asString?x.bytesToString(r):m.bytesToHex(r)}});function q(t,e){var r=e.method,n=e.path,o=[r,encodeURI(n)];["date","policy","contentMd5"].forEach(function(t){e[t]&&o.push(e[t])});var i=b(t.password,o.join("&"));return"UPYUN "+t.operatorName+":"+i}function I(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var T={genSign:q,getHeaderSign:function(t,e,r){var n=3