Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c0b9bf6

Browse files
committedJul 15, 2019
3.3.11
1 parent ce41791 commit c0b9bf6

File tree

5 files changed

+69
-51
lines changed

5 files changed

+69
-51
lines changed
 

‎dist/upyun.common.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* UPYUN js-sdk 3.3.10
2+
* UPYUN js-sdk 3.3.11
33
* (c) 2019
44
* @license MIT
55
*/
@@ -138,14 +138,17 @@ function formUpload(remoteUrl, localFile, _ref) {
138138
var authorization = _ref.authorization,
139139
policy = _ref.policy;
140140

141+
var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
142+
filename = _ref2.filename;
143+
141144
return new Promise(function (resolve, reject) {
142145
var data = new FormData();
143146
data.append('authorization', authorization);
144147
data.append('policy', policy);
145148
// NOTE when type of localFile is buffer/string,
146149
// force set filename=file, FormData will treat it as a file
147150
// real filename will be set by save-key in policy
148-
var filename = localFile.name || localFile.path ? path.basename(localFile.name || localFile.path) : 'file';
151+
filename = filename || localFile.name || localFile.path ? path.basename(filename || localFile.name || localFile.path) : 'file';
149152

150153
data.append('file', localFile, {
151154
filename: filename
@@ -181,7 +184,7 @@ function formUpload(remoteUrl, localFile, _ref) {
181184
}
182185

183186
var name = "upyun";
184-
var version = "3.3.10";
187+
var version = "3.3.11";
185188
var description = "UPYUN js sdk";
186189
var main = "dist/upyun.common.js";
187190
var module$1 = "dist/upyun.esm.js";
@@ -978,6 +981,7 @@ var Upyun = function () {
978981
var _this4 = this;
979982

980983
var orignParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
984+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
981985

982986
var params = {};
983987
var _iteratorNormalCompletion3 = true;
@@ -1015,7 +1019,7 @@ var Upyun = function () {
10151019
result = isPromise(result) ? result : Promise.resolve(result);
10161020

10171021
return result.then(function (bodySign) {
1018-
return formUpload(_this4.endpoint + '/' + params['service'], localFile, bodySign);
1022+
return formUpload(_this4.endpoint + '/' + params['service'], localFile, bodySign, opts);
10191023
});
10201024
}
10211025
}, {

‎dist/upyun.esm.js

+27-20
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/**
2-
* UPYUN js-sdk 3.3.10
2+
* UPYUN js-sdk 3.3.11
33
* (c) 2019
44
* @license MIT
55
*/
66
import axios from 'axios';
7+
import path from 'path';
78

89
// NOTE: choose node.js first
910
// process is defined in client test
@@ -1447,13 +1448,13 @@ var createReq = function (endpoint, service, getHeaderSign) {
14471448

14481449
req.interceptors.request.use(function (config) {
14491450
var method = config.method.toUpperCase();
1450-
var path = url.resolve('/', config.url || '');
1451+
var path$$1 = url.resolve('/', config.url || '');
14511452

1452-
if (path.indexOf(config.baseURL) === 0) {
1453-
path = path.substring(config.baseURL.length);
1453+
if (path$$1.indexOf(config.baseURL) === 0) {
1454+
path$$1 = path$$1.substring(config.baseURL.length);
14541455
}
14551456
config.url = encodeURI(config.url);
1456-
var headerSign = getHeaderSign(service, method, path, config.headers['Content-MD5']);
1457+
var headerSign = getHeaderSign(service, method, path$$1, config.headers['Content-MD5']);
14571458
headerSign = isPromise_1(headerSign) ? headerSign : Promise.resolve(headerSign);
14581459

14591460
return headerSign.then(function (headers) {
@@ -1501,16 +1502,21 @@ function formUpload(remoteUrl, localFile, _ref) {
15011502
var authorization = _ref.authorization,
15021503
policy = _ref.policy;
15031504

1505+
var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
1506+
filename = _ref2.filename;
1507+
15041508
var data = new FormData();
15051509
data.append('authorization', authorization);
15061510
data.append('policy', policy);
15071511
if (typeof localFile === 'string') {
15081512
localFile = new Blob([localFile], { type: 'text/plain' });
15091513
}
1510-
data.append('file', localFile);
1511-
return axios.post(remoteUrl, data).then(function (_ref2) {
1512-
var status = _ref2.status,
1513-
data = _ref2.data;
1514+
1515+
filename = filename ? path.basename(filename) : filename;
1516+
data.append('file', localFile, filename);
1517+
return axios.post(remoteUrl, data).then(function (_ref3) {
1518+
var status = _ref3.status,
1519+
data = _ref3.data;
15141520

15151521
if (status === 200) {
15161522
return Promise.resolve(data);
@@ -1737,7 +1743,7 @@ var base64 = createCommonjsModule(function (module, exports) {
17371743
});
17381744

17391745
var name = "upyun";
1740-
var version = "3.3.10";
1746+
var version = "3.3.11";
17411747
var description = "UPYUN js sdk";
17421748
var main = "dist/upyun.common.js";
17431749
var module$1 = "dist/upyun.esm.js";
@@ -2097,14 +2103,14 @@ var md5 = createCommonjsModule(function (module) {
20972103
* @param {string} path - storage path on upyun server, e.g: /your/dir/example.txt
20982104
* @param {string} contentMd5 - md5 of the file that will be uploaded
20992105
*/
2100-
function getHeaderSign(service, method, path) {
2106+
function getHeaderSign(service, method, path$$1) {
21012107
var contentMd5 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
21022108

21032109
var date = new Date().toGMTString();
2104-
path = '/' + service.serviceName + path;
2110+
path$$1 = '/' + service.serviceName + path$$1;
21052111
var sign = genSign(service, {
21062112
method: method,
2107-
path: path,
2113+
path: path$$1,
21082114
date: date,
21092115
contentMd5: contentMd5
21102116
});
@@ -2121,10 +2127,10 @@ function getHeaderSign(service, method, path) {
21212127
*/
21222128
function genSign(service, options) {
21232129
var method = options.method,
2124-
path = options.path;
2130+
path$$1 = options.path;
21252131

21262132

2127-
var data = [method, encodeURI(path)];
2133+
var data = [method, encodeURI(path$$1)];
21282134

21292135
// optional params
21302136
['date', 'policy', 'contentMd5'].forEach(function (item) {
@@ -2350,9 +2356,9 @@ var Upyun = function () {
23502356
}, {
23512357
key: 'usage',
23522358
value: function usage() {
2353-
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
2359+
var path$$1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
23542360

2355-
return this.req.get(path + '?usage').then(function (_ref) {
2361+
return this.req.get(path$$1 + '?usage').then(function (_ref) {
23562362
var data = _ref.data;
23572363

23582364
return Promise.resolve(data);
@@ -2361,7 +2367,7 @@ var Upyun = function () {
23612367
}, {
23622368
key: 'listDir',
23632369
value: function listDir() {
2364-
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
2370+
var path$$1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
23652371

23662372
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
23672373
_ref2$limit = _ref2.limit,
@@ -2386,7 +2392,7 @@ var Upyun = function () {
23862392
requestHeaders['x-list-iter'] = iter;
23872393
}
23882394

2389-
return this.req.get(path, {
2395+
return this.req.get(path$$1, {
23902396
headers: requestHeaders
23912397
}).then(function (_ref3) {
23922398
var data = _ref3.data,
@@ -2852,6 +2858,7 @@ var Upyun = function () {
28522858
var _this4 = this;
28532859

28542860
var orignParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2861+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
28552862

28562863
var params = {};
28572864
var _iteratorNormalCompletion3 = true;
@@ -2889,7 +2896,7 @@ var Upyun = function () {
28892896
result = isPromise_1(result) ? result : Promise.resolve(result);
28902897

28912898
return result.then(function (bodySign) {
2892-
return formUpload(_this4.endpoint + '/' + params['service'], localFile, bodySign);
2899+
return formUpload(_this4.endpoint + '/' + params['service'], localFile, bodySign, opts);
28932900
});
28942901
}
28952902
}, {

‎dist/upyun.js

+31-24
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
/**
2-
* UPYUN js-sdk 3.3.10
2+
* UPYUN js-sdk 3.3.11
33
* (c) 2019
44
* @license MIT
55
*/
66
(function (global, factory) {
7-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('axios')) :
8-
typeof define === 'function' && define.amd ? define(['axios'], factory) :
9-
(global.upyun = factory(global.axios));
10-
}(this, (function (axios) { 'use strict';
7+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('axios'), require('path')) :
8+
typeof define === 'function' && define.amd ? define(['axios', 'path'], factory) :
9+
(global.upyun = factory(global.axios,global.path));
10+
}(this, (function (axios,path) { 'use strict';
1111

1212
axios = 'default' in axios ? axios['default'] : axios;
13+
path = 'default' in path ? path['default'] : path;
1314

1415
// NOTE: choose node.js first
1516
// process is defined in client test
@@ -1453,13 +1454,13 @@ var createReq = function (endpoint, service, getHeaderSign) {
14531454

14541455
req.interceptors.request.use(function (config) {
14551456
var method = config.method.toUpperCase();
1456-
var path = url.resolve('/', config.url || '');
1457+
var path$$1 = url.resolve('/', config.url || '');
14571458

1458-
if (path.indexOf(config.baseURL) === 0) {
1459-
path = path.substring(config.baseURL.length);
1459+
if (path$$1.indexOf(config.baseURL) === 0) {
1460+
path$$1 = path$$1.substring(config.baseURL.length);
14601461
}
14611462
config.url = encodeURI(config.url);
1462-
var headerSign = getHeaderSign(service, method, path, config.headers['Content-MD5']);
1463+
var headerSign = getHeaderSign(service, method, path$$1, config.headers['Content-MD5']);
14631464
headerSign = isPromise_1(headerSign) ? headerSign : Promise.resolve(headerSign);
14641465

14651466
return headerSign.then(function (headers) {
@@ -1507,16 +1508,21 @@ function formUpload(remoteUrl, localFile, _ref) {
15071508
var authorization = _ref.authorization,
15081509
policy = _ref.policy;
15091510

1511+
var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
1512+
filename = _ref2.filename;
1513+
15101514
var data = new FormData();
15111515
data.append('authorization', authorization);
15121516
data.append('policy', policy);
15131517
if (typeof localFile === 'string') {
15141518
localFile = new Blob([localFile], { type: 'text/plain' });
15151519
}
1516-
data.append('file', localFile);
1517-
return axios.post(remoteUrl, data).then(function (_ref2) {
1518-
var status = _ref2.status,
1519-
data = _ref2.data;
1520+
1521+
filename = filename ? path.basename(filename) : filename;
1522+
data.append('file', localFile, filename);
1523+
return axios.post(remoteUrl, data).then(function (_ref3) {
1524+
var status = _ref3.status,
1525+
data = _ref3.data;
15201526

15211527
if (status === 200) {
15221528
return Promise.resolve(data);
@@ -1743,7 +1749,7 @@ var base64 = createCommonjsModule(function (module, exports) {
17431749
});
17441750

17451751
var name = "upyun";
1746-
var version = "3.3.10";
1752+
var version = "3.3.11";
17471753
var description = "UPYUN js sdk";
17481754
var main = "dist/upyun.common.js";
17491755
var module$1 = "dist/upyun.esm.js";
@@ -2103,14 +2109,14 @@ var md5 = createCommonjsModule(function (module) {
21032109
* @param {string} path - storage path on upyun server, e.g: /your/dir/example.txt
21042110
* @param {string} contentMd5 - md5 of the file that will be uploaded
21052111
*/
2106-
function getHeaderSign(service, method, path) {
2112+
function getHeaderSign(service, method, path$$1) {
21072113
var contentMd5 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
21082114

21092115
var date = new Date().toGMTString();
2110-
path = '/' + service.serviceName + path;
2116+
path$$1 = '/' + service.serviceName + path$$1;
21112117
var sign = genSign(service, {
21122118
method: method,
2113-
path: path,
2119+
path: path$$1,
21142120
date: date,
21152121
contentMd5: contentMd5
21162122
});
@@ -2127,10 +2133,10 @@ function getHeaderSign(service, method, path) {
21272133
*/
21282134
function genSign(service, options) {
21292135
var method = options.method,
2130-
path = options.path;
2136+
path$$1 = options.path;
21312137

21322138

2133-
var data = [method, encodeURI(path)];
2139+
var data = [method, encodeURI(path$$1)];
21342140

21352141
// optional params
21362142
['date', 'policy', 'contentMd5'].forEach(function (item) {
@@ -2356,9 +2362,9 @@ var Upyun = function () {
23562362
}, {
23572363
key: 'usage',
23582364
value: function usage() {
2359-
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
2365+
var path$$1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
23602366

2361-
return this.req.get(path + '?usage').then(function (_ref) {
2367+
return this.req.get(path$$1 + '?usage').then(function (_ref) {
23622368
var data = _ref.data;
23632369

23642370
return Promise.resolve(data);
@@ -2367,7 +2373,7 @@ var Upyun = function () {
23672373
}, {
23682374
key: 'listDir',
23692375
value: function listDir() {
2370-
var path = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
2376+
var path$$1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
23712377

23722378
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
23732379
_ref2$limit = _ref2.limit,
@@ -2392,7 +2398,7 @@ var Upyun = function () {
23922398
requestHeaders['x-list-iter'] = iter;
23932399
}
23942400

2395-
return this.req.get(path, {
2401+
return this.req.get(path$$1, {
23962402
headers: requestHeaders
23972403
}).then(function (_ref3) {
23982404
var data = _ref3.data,
@@ -2858,6 +2864,7 @@ var Upyun = function () {
28582864
var _this4 = this;
28592865

28602866
var orignParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2867+
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
28612868

28622869
var params = {};
28632870
var _iteratorNormalCompletion3 = true;
@@ -2895,7 +2902,7 @@ var Upyun = function () {
28952902
result = isPromise_1(result) ? result : Promise.resolve(result);
28962903

28972904
return result.then(function (bodySign) {
2898-
return formUpload(_this4.endpoint + '/' + params['service'], localFile, bodySign);
2905+
return formUpload(_this4.endpoint + '/' + params['service'], localFile, bodySign, opts);
28992906
});
29002907
}
29012908
}, {

‎dist/upyun.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "upyun",
3-
"version": "3.3.10",
3+
"version": "3.3.11",
44
"description": "UPYUN js sdk",
55
"main": "dist/upyun.common.js",
66
"module": "dist/upyun.esm.js",

0 commit comments

Comments
 (0)
Please sign in to comment.