parse 3.4.2 → 3.4.3-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/parse.js +52 -46
- package/dist/parse.min.js +2 -2
- package/dist/parse.weapp.js +52 -46
- package/dist/parse.weapp.min.js +2 -2
- package/lib/browser/CoreManager.js +1 -1
- package/lib/browser/ParseFile.js +52 -46
- package/lib/node/CoreManager.js +1 -1
- package/lib/node/ParseFile.js +20 -18
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/react-native/ParseFile.js +20 -19
- package/lib/weapp/CoreManager.js +1 -1
- package/lib/weapp/ParseFile.js +52 -46
- package/package.json +1 -1
package/lib/browser/ParseFile.js
CHANGED
|
@@ -24,6 +24,8 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
24
24
|
|
|
25
25
|
exports.default = void 0;
|
|
26
26
|
|
|
27
|
+
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
28
|
+
|
|
27
29
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
28
30
|
|
|
29
31
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
@@ -40,8 +42,6 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/
|
|
|
40
42
|
|
|
41
43
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
42
44
|
|
|
43
|
-
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
44
|
-
|
|
45
45
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
46
46
|
|
|
47
47
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
@@ -68,12 +68,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
68
68
|
|
|
69
69
|
function _objectSpread(target) {
|
|
70
70
|
for (var i = 1; i < arguments.length; i++) {
|
|
71
|
-
var
|
|
71
|
+
var _context8, _context9;
|
|
72
72
|
|
|
73
73
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
74
|
-
i % 2 ? _forEachInstanceProperty2(
|
|
74
|
+
i % 2 ? _forEachInstanceProperty2(_context8 = ownKeys(Object(source), !0)).call(_context8, function (key) {
|
|
75
75
|
(0, _defineProperty2.default)(target, key, source[key]);
|
|
76
|
-
}) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(
|
|
76
|
+
}) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context9 = ownKeys(Object(source))).call(_context9, function (key) {
|
|
77
77
|
_Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
|
|
78
78
|
});
|
|
79
79
|
}
|
|
@@ -111,7 +111,8 @@ if (typeof XMLHttpRequest !== 'undefined') {
|
|
|
111
111
|
uri: string,
|
|
112
112
|
type: string,
|
|
113
113
|
};*/
|
|
114
|
-
var
|
|
114
|
+
var base64Regex = new RegExp('([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))', 'i');
|
|
115
|
+
var dataUriRegex = new RegExp("^data:([a-zA-Z]+\\/[-a-zA-Z0-9+.]+(;[a-z-]+=[a-zA-Z0-9+.-]+)?)?(;base64)?,(".concat(base64Regex.source, ")*$"), 'i');
|
|
115
116
|
|
|
116
117
|
function b64Digit(number
|
|
117
118
|
/*: number*/
|
|
@@ -225,26 +226,31 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
225
226
|
type: specifiedType
|
|
226
227
|
};
|
|
227
228
|
} else if (data && typeof data.base64 === 'string') {
|
|
228
|
-
var
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
this._source = {
|
|
236
|
-
format: 'base64',
|
|
237
|
-
base64: this._data,
|
|
238
|
-
type: matches[1]
|
|
239
|
-
};
|
|
240
|
-
} else {
|
|
241
|
-
this._data = base64;
|
|
242
|
-
this._source = {
|
|
243
|
-
format: 'base64',
|
|
244
|
-
base64: base64,
|
|
245
|
-
type: specifiedType
|
|
246
|
-
};
|
|
229
|
+
var _context, _context2, _context3; // Check if data URI or base64 string is valid
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
var validationRegex = new RegExp(base64Regex.source + '|' + dataUriRegex.source, 'i');
|
|
233
|
+
|
|
234
|
+
if (!validationRegex.test(data.base64)) {
|
|
235
|
+
throw new Error('Cannot create a Parse.File without valid data URIs or base64 encoded data.');
|
|
247
236
|
}
|
|
237
|
+
|
|
238
|
+
var base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
|
|
239
|
+
|
|
240
|
+
var _type = specifiedType || (0, _slice.default)(_context2 = (0, _slice.default)(_context3 = data.base64.split(';')).call(_context3, 0, 1)[0].split(':')).call(_context2, 1, 2)[0] || ''; // https://tools.ietf.org/html/rfc2397
|
|
241
|
+
// If <mediatype> is omitted, it defaults to text/plain;charset=US-ASCII.
|
|
242
|
+
// As a shorthand, "text/plain" can be omitted but the charset parameter supplied.
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
if (dataUriRegex.test(data.base64)) {
|
|
246
|
+
_type = _type || 'text/plain';
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
this._source = {
|
|
250
|
+
format: 'base64',
|
|
251
|
+
base64: base64,
|
|
252
|
+
type: _type
|
|
253
|
+
};
|
|
248
254
|
} else {
|
|
249
255
|
throw new TypeError('Cannot create a Parse.File with that data.');
|
|
250
256
|
}
|
|
@@ -266,20 +272,20 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
266
272
|
var _this = this;
|
|
267
273
|
|
|
268
274
|
var options, controller, result;
|
|
269
|
-
return _regenerator.default.wrap(function (
|
|
275
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
270
276
|
while (1) {
|
|
271
|
-
switch (
|
|
277
|
+
switch (_context4.prev = _context4.next) {
|
|
272
278
|
case 0:
|
|
273
279
|
if (!this._data) {
|
|
274
|
-
|
|
280
|
+
_context4.next = 2;
|
|
275
281
|
break;
|
|
276
282
|
}
|
|
277
283
|
|
|
278
|
-
return
|
|
284
|
+
return _context4.abrupt("return", this._data);
|
|
279
285
|
|
|
280
286
|
case 2:
|
|
281
287
|
if (this._url) {
|
|
282
|
-
|
|
288
|
+
_context4.next = 4;
|
|
283
289
|
break;
|
|
284
290
|
}
|
|
285
291
|
|
|
@@ -292,17 +298,17 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
292
298
|
}
|
|
293
299
|
};
|
|
294
300
|
controller = _CoreManager.default.getFileController();
|
|
295
|
-
|
|
301
|
+
_context4.next = 8;
|
|
296
302
|
return controller.download(this._url, options);
|
|
297
303
|
|
|
298
304
|
case 8:
|
|
299
|
-
result =
|
|
305
|
+
result = _context4.sent;
|
|
300
306
|
this._data = result.base64;
|
|
301
|
-
return
|
|
307
|
+
return _context4.abrupt("return", this._data);
|
|
302
308
|
|
|
303
309
|
case 11:
|
|
304
310
|
case "end":
|
|
305
|
-
return
|
|
311
|
+
return _context4.stop();
|
|
306
312
|
}
|
|
307
313
|
}
|
|
308
314
|
}, _callee, this);
|
|
@@ -558,9 +564,9 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
558
564
|
var _this4 = this;
|
|
559
565
|
|
|
560
566
|
if (metadata && (0, _typeof2.default)(metadata) === 'object') {
|
|
561
|
-
var
|
|
567
|
+
var _context5;
|
|
562
568
|
|
|
563
|
-
(0, _forEach.default)(
|
|
569
|
+
(0, _forEach.default)(_context5 = (0, _keys.default)(metadata)).call(_context5, function (key) {
|
|
564
570
|
_this4.addMetadata(key, metadata[key]);
|
|
565
571
|
});
|
|
566
572
|
}
|
|
@@ -597,9 +603,9 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
597
603
|
var _this5 = this;
|
|
598
604
|
|
|
599
605
|
if (tags && (0, _typeof2.default)(tags) === 'object') {
|
|
600
|
-
var
|
|
606
|
+
var _context6;
|
|
601
607
|
|
|
602
|
-
(0, _forEach.default)(
|
|
608
|
+
(0, _forEach.default)(_context6 = (0, _keys.default)(tags)).call(_context6, function (key) {
|
|
603
609
|
_this5.addTag(key, tags[key]);
|
|
604
610
|
});
|
|
605
611
|
}
|
|
@@ -671,19 +677,19 @@ var DefaultController = {
|
|
|
671
677
|
) {
|
|
672
678
|
var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
|
|
673
679
|
|
|
674
|
-
return _regenerator.default.wrap(function (
|
|
680
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
675
681
|
while (1) {
|
|
676
|
-
switch (
|
|
682
|
+
switch (_context7.prev = _context7.next) {
|
|
677
683
|
case 0:
|
|
678
684
|
if (!(source.format !== 'file')) {
|
|
679
|
-
|
|
685
|
+
_context7.next = 2;
|
|
680
686
|
break;
|
|
681
687
|
}
|
|
682
688
|
|
|
683
689
|
throw new Error('saveFile can only be used with File-type sources.');
|
|
684
690
|
|
|
685
691
|
case 2:
|
|
686
|
-
|
|
692
|
+
_context7.next = 4;
|
|
687
693
|
return new _promise.default(function (res, rej) {
|
|
688
694
|
// eslint-disable-next-line no-undef
|
|
689
695
|
var reader = new FileReader();
|
|
@@ -700,7 +706,7 @@ var DefaultController = {
|
|
|
700
706
|
});
|
|
701
707
|
|
|
702
708
|
case 4:
|
|
703
|
-
base64Data =
|
|
709
|
+
base64Data = _context7.sent; // we only want the data after the comma
|
|
704
710
|
// For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
|
|
705
711
|
|
|
706
712
|
_base64Data$split = base64Data.split(','), _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2), first = _base64Data$split2[0], second = _base64Data$split2[1]; // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
|
|
@@ -712,15 +718,15 @@ var DefaultController = {
|
|
|
712
718
|
base64: data,
|
|
713
719
|
type: source.type || (source.file ? source.file.type : null)
|
|
714
720
|
};
|
|
715
|
-
|
|
721
|
+
_context7.next = 10;
|
|
716
722
|
return DefaultController.saveBase64(name, newSource, options);
|
|
717
723
|
|
|
718
724
|
case 10:
|
|
719
|
-
return
|
|
725
|
+
return _context7.abrupt("return", _context7.sent);
|
|
720
726
|
|
|
721
727
|
case 11:
|
|
722
728
|
case "end":
|
|
723
|
-
return
|
|
729
|
+
return _context7.stop();
|
|
724
730
|
}
|
|
725
731
|
}
|
|
726
732
|
}, _callee2);
|
package/lib/node/CoreManager.js
CHANGED
package/lib/node/ParseFile.js
CHANGED
|
@@ -84,7 +84,8 @@ if (typeof XMLHttpRequest !== 'undefined') {
|
|
|
84
84
|
uri: string,
|
|
85
85
|
type: string,
|
|
86
86
|
};*/
|
|
87
|
-
const
|
|
87
|
+
const base64Regex = new RegExp('([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))', 'i');
|
|
88
|
+
const dataUriRegex = new RegExp(`^data:([a-zA-Z]+\\/[-a-zA-Z0-9+.]+(;[a-z-]+=[a-zA-Z0-9+.-]+)?)?(;base64)?,(${base64Regex.source})*$`, 'i');
|
|
88
89
|
|
|
89
90
|
function b64Digit(number
|
|
90
91
|
/*: number*/
|
|
@@ -205,26 +206,27 @@ class ParseFile {
|
|
|
205
206
|
type: specifiedType
|
|
206
207
|
};
|
|
207
208
|
} else if (data && typeof data.base64 === 'string') {
|
|
208
|
-
|
|
209
|
-
const
|
|
209
|
+
// Check if data URI or base64 string is valid
|
|
210
|
+
const validationRegex = new RegExp(base64Regex.source + '|' + dataUriRegex.source, 'i');
|
|
210
211
|
|
|
211
|
-
if (
|
|
212
|
-
|
|
212
|
+
if (!validationRegex.test(data.base64)) {
|
|
213
|
+
throw new Error('Cannot create a Parse.File without valid data URIs or base64 encoded data.');
|
|
214
|
+
}
|
|
213
215
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
this._data = base64;
|
|
222
|
-
this._source = {
|
|
223
|
-
format: 'base64',
|
|
224
|
-
base64: base64,
|
|
225
|
-
type: specifiedType
|
|
226
|
-
};
|
|
216
|
+
const base64 = data.base64.split(',').slice(-1)[0];
|
|
217
|
+
let type = specifiedType || data.base64.split(';').slice(0, 1)[0].split(':').slice(1, 2)[0] || ''; // https://tools.ietf.org/html/rfc2397
|
|
218
|
+
// If <mediatype> is omitted, it defaults to text/plain;charset=US-ASCII.
|
|
219
|
+
// As a shorthand, "text/plain" can be omitted but the charset parameter supplied.
|
|
220
|
+
|
|
221
|
+
if (dataUriRegex.test(data.base64)) {
|
|
222
|
+
type = type || 'text/plain';
|
|
227
223
|
}
|
|
224
|
+
|
|
225
|
+
this._source = {
|
|
226
|
+
format: 'base64',
|
|
227
|
+
base64,
|
|
228
|
+
type
|
|
229
|
+
};
|
|
228
230
|
} else {
|
|
229
231
|
throw new TypeError('Cannot create a Parse.File with that data.');
|
|
230
232
|
}
|
|
@@ -51,7 +51,8 @@ if (typeof XMLHttpRequest !== 'undefined') {
|
|
|
51
51
|
XHR = XMLHttpRequest;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
var
|
|
54
|
+
var base64Regex = new RegExp('([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))', 'i');
|
|
55
|
+
var dataUriRegex = new RegExp("^data:([a-zA-Z]+\\/[-a-zA-Z0-9+.]+(;[a-z-]+=[a-zA-Z0-9+.-]+)?)?(;base64)?,(" + base64Regex.source + ")*$", 'i');
|
|
55
56
|
|
|
56
57
|
function b64Digit(number) {
|
|
57
58
|
if (number < 26) {
|
|
@@ -106,25 +107,25 @@ var ParseFile = function () {
|
|
|
106
107
|
type: specifiedType
|
|
107
108
|
};
|
|
108
109
|
} else if (data && typeof data.base64 === 'string') {
|
|
109
|
-
var
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
this._data = base64;
|
|
122
|
-
this._source = {
|
|
123
|
-
format: 'base64',
|
|
124
|
-
base64: base64,
|
|
125
|
-
type: specifiedType
|
|
126
|
-
};
|
|
110
|
+
var validationRegex = new RegExp(base64Regex.source + '|' + dataUriRegex.source, 'i');
|
|
111
|
+
|
|
112
|
+
if (!validationRegex.test(data.base64)) {
|
|
113
|
+
throw new Error('Cannot create a Parse.File without valid data URIs or base64 encoded data.');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
var base64 = data.base64.split(',').slice(-1)[0];
|
|
117
|
+
|
|
118
|
+
var _type = specifiedType || data.base64.split(';').slice(0, 1)[0].split(':').slice(1, 2)[0] || '';
|
|
119
|
+
|
|
120
|
+
if (dataUriRegex.test(data.base64)) {
|
|
121
|
+
_type = _type || 'text/plain';
|
|
127
122
|
}
|
|
123
|
+
|
|
124
|
+
this._source = {
|
|
125
|
+
format: 'base64',
|
|
126
|
+
base64: base64,
|
|
127
|
+
type: _type
|
|
128
|
+
};
|
|
128
129
|
} else {
|
|
129
130
|
throw new TypeError('Cannot create a Parse.File with that data.');
|
|
130
131
|
}
|
package/lib/weapp/CoreManager.js
CHANGED
package/lib/weapp/ParseFile.js
CHANGED
|
@@ -24,6 +24,8 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
24
24
|
|
|
25
25
|
exports.default = void 0;
|
|
26
26
|
|
|
27
|
+
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
28
|
+
|
|
27
29
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
28
30
|
|
|
29
31
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
@@ -40,8 +42,6 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/
|
|
|
40
42
|
|
|
41
43
|
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
42
44
|
|
|
43
|
-
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
44
|
-
|
|
45
45
|
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
|
|
46
46
|
|
|
47
47
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
@@ -68,12 +68,12 @@ function ownKeys(object, enumerableOnly) {
|
|
|
68
68
|
|
|
69
69
|
function _objectSpread(target) {
|
|
70
70
|
for (var i = 1; i < arguments.length; i++) {
|
|
71
|
-
var
|
|
71
|
+
var _context8, _context9;
|
|
72
72
|
|
|
73
73
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
74
|
-
i % 2 ? _forEachInstanceProperty2(
|
|
74
|
+
i % 2 ? _forEachInstanceProperty2(_context8 = ownKeys(Object(source), !0)).call(_context8, function (key) {
|
|
75
75
|
(0, _defineProperty2.default)(target, key, source[key]);
|
|
76
|
-
}) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(
|
|
76
|
+
}) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context9 = ownKeys(Object(source))).call(_context9, function (key) {
|
|
77
77
|
_Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key));
|
|
78
78
|
});
|
|
79
79
|
}
|
|
@@ -113,7 +113,8 @@ XHR = require('./Xhr.weapp');
|
|
|
113
113
|
type: string,
|
|
114
114
|
};*/
|
|
115
115
|
|
|
116
|
-
var
|
|
116
|
+
var base64Regex = new RegExp('([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))', 'i');
|
|
117
|
+
var dataUriRegex = new RegExp("^data:([a-zA-Z]+\\/[-a-zA-Z0-9+.]+(;[a-z-]+=[a-zA-Z0-9+.-]+)?)?(;base64)?,(".concat(base64Regex.source, ")*$"), 'i');
|
|
117
118
|
|
|
118
119
|
function b64Digit(number
|
|
119
120
|
/*: number*/
|
|
@@ -227,26 +228,31 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
227
228
|
type: specifiedType
|
|
228
229
|
};
|
|
229
230
|
} else if (data && typeof data.base64 === 'string') {
|
|
230
|
-
var
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
this._source = {
|
|
238
|
-
format: 'base64',
|
|
239
|
-
base64: this._data,
|
|
240
|
-
type: matches[1]
|
|
241
|
-
};
|
|
242
|
-
} else {
|
|
243
|
-
this._data = base64;
|
|
244
|
-
this._source = {
|
|
245
|
-
format: 'base64',
|
|
246
|
-
base64: base64,
|
|
247
|
-
type: specifiedType
|
|
248
|
-
};
|
|
231
|
+
var _context, _context2, _context3; // Check if data URI or base64 string is valid
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
var validationRegex = new RegExp(base64Regex.source + '|' + dataUriRegex.source, 'i');
|
|
235
|
+
|
|
236
|
+
if (!validationRegex.test(data.base64)) {
|
|
237
|
+
throw new Error('Cannot create a Parse.File without valid data URIs or base64 encoded data.');
|
|
249
238
|
}
|
|
239
|
+
|
|
240
|
+
var base64 = (0, _slice.default)(_context = data.base64.split(',')).call(_context, -1)[0];
|
|
241
|
+
|
|
242
|
+
var _type = specifiedType || (0, _slice.default)(_context2 = (0, _slice.default)(_context3 = data.base64.split(';')).call(_context3, 0, 1)[0].split(':')).call(_context2, 1, 2)[0] || ''; // https://tools.ietf.org/html/rfc2397
|
|
243
|
+
// If <mediatype> is omitted, it defaults to text/plain;charset=US-ASCII.
|
|
244
|
+
// As a shorthand, "text/plain" can be omitted but the charset parameter supplied.
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
if (dataUriRegex.test(data.base64)) {
|
|
248
|
+
_type = _type || 'text/plain';
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
this._source = {
|
|
252
|
+
format: 'base64',
|
|
253
|
+
base64: base64,
|
|
254
|
+
type: _type
|
|
255
|
+
};
|
|
250
256
|
} else {
|
|
251
257
|
throw new TypeError('Cannot create a Parse.File with that data.');
|
|
252
258
|
}
|
|
@@ -268,20 +274,20 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
268
274
|
var _this = this;
|
|
269
275
|
|
|
270
276
|
var options, controller, result;
|
|
271
|
-
return _regenerator.default.wrap(function (
|
|
277
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
272
278
|
while (1) {
|
|
273
|
-
switch (
|
|
279
|
+
switch (_context4.prev = _context4.next) {
|
|
274
280
|
case 0:
|
|
275
281
|
if (!this._data) {
|
|
276
|
-
|
|
282
|
+
_context4.next = 2;
|
|
277
283
|
break;
|
|
278
284
|
}
|
|
279
285
|
|
|
280
|
-
return
|
|
286
|
+
return _context4.abrupt("return", this._data);
|
|
281
287
|
|
|
282
288
|
case 2:
|
|
283
289
|
if (this._url) {
|
|
284
|
-
|
|
290
|
+
_context4.next = 4;
|
|
285
291
|
break;
|
|
286
292
|
}
|
|
287
293
|
|
|
@@ -294,17 +300,17 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
294
300
|
}
|
|
295
301
|
};
|
|
296
302
|
controller = _CoreManager.default.getFileController();
|
|
297
|
-
|
|
303
|
+
_context4.next = 8;
|
|
298
304
|
return controller.download(this._url, options);
|
|
299
305
|
|
|
300
306
|
case 8:
|
|
301
|
-
result =
|
|
307
|
+
result = _context4.sent;
|
|
302
308
|
this._data = result.base64;
|
|
303
|
-
return
|
|
309
|
+
return _context4.abrupt("return", this._data);
|
|
304
310
|
|
|
305
311
|
case 11:
|
|
306
312
|
case "end":
|
|
307
|
-
return
|
|
313
|
+
return _context4.stop();
|
|
308
314
|
}
|
|
309
315
|
}
|
|
310
316
|
}, _callee, this);
|
|
@@ -560,9 +566,9 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
560
566
|
var _this4 = this;
|
|
561
567
|
|
|
562
568
|
if (metadata && (0, _typeof2.default)(metadata) === 'object') {
|
|
563
|
-
var
|
|
569
|
+
var _context5;
|
|
564
570
|
|
|
565
|
-
(0, _forEach.default)(
|
|
571
|
+
(0, _forEach.default)(_context5 = (0, _keys.default)(metadata)).call(_context5, function (key) {
|
|
566
572
|
_this4.addMetadata(key, metadata[key]);
|
|
567
573
|
});
|
|
568
574
|
}
|
|
@@ -599,9 +605,9 @@ var ParseFile = /*#__PURE__*/function () {
|
|
|
599
605
|
var _this5 = this;
|
|
600
606
|
|
|
601
607
|
if (tags && (0, _typeof2.default)(tags) === 'object') {
|
|
602
|
-
var
|
|
608
|
+
var _context6;
|
|
603
609
|
|
|
604
|
-
(0, _forEach.default)(
|
|
610
|
+
(0, _forEach.default)(_context6 = (0, _keys.default)(tags)).call(_context6, function (key) {
|
|
605
611
|
_this5.addTag(key, tags[key]);
|
|
606
612
|
});
|
|
607
613
|
}
|
|
@@ -673,19 +679,19 @@ var DefaultController = {
|
|
|
673
679
|
) {
|
|
674
680
|
var base64Data, _base64Data$split, _base64Data$split2, first, second, data, newSource;
|
|
675
681
|
|
|
676
|
-
return _regenerator.default.wrap(function (
|
|
682
|
+
return _regenerator.default.wrap(function (_context7) {
|
|
677
683
|
while (1) {
|
|
678
|
-
switch (
|
|
684
|
+
switch (_context7.prev = _context7.next) {
|
|
679
685
|
case 0:
|
|
680
686
|
if (!(source.format !== 'file')) {
|
|
681
|
-
|
|
687
|
+
_context7.next = 2;
|
|
682
688
|
break;
|
|
683
689
|
}
|
|
684
690
|
|
|
685
691
|
throw new Error('saveFile can only be used with File-type sources.');
|
|
686
692
|
|
|
687
693
|
case 2:
|
|
688
|
-
|
|
694
|
+
_context7.next = 4;
|
|
689
695
|
return new _promise.default(function (res, rej) {
|
|
690
696
|
// eslint-disable-next-line no-undef
|
|
691
697
|
var reader = new FileReader();
|
|
@@ -702,7 +708,7 @@ var DefaultController = {
|
|
|
702
708
|
});
|
|
703
709
|
|
|
704
710
|
case 4:
|
|
705
|
-
base64Data =
|
|
711
|
+
base64Data = _context7.sent; // we only want the data after the comma
|
|
706
712
|
// For example: "data:application/pdf;base64,JVBERi0xLjQKJ..." we would only want "JVBERi0xLjQKJ..."
|
|
707
713
|
|
|
708
714
|
_base64Data$split = base64Data.split(','), _base64Data$split2 = (0, _slicedToArray2.default)(_base64Data$split, 2), first = _base64Data$split2[0], second = _base64Data$split2[1]; // in the event there is no 'data:application/pdf;base64,' at the beginning of the base64 string
|
|
@@ -714,15 +720,15 @@ var DefaultController = {
|
|
|
714
720
|
base64: data,
|
|
715
721
|
type: source.type || (source.file ? source.file.type : null)
|
|
716
722
|
};
|
|
717
|
-
|
|
723
|
+
_context7.next = 10;
|
|
718
724
|
return DefaultController.saveBase64(name, newSource, options);
|
|
719
725
|
|
|
720
726
|
case 10:
|
|
721
|
-
return
|
|
727
|
+
return _context7.abrupt("return", _context7.sent);
|
|
722
728
|
|
|
723
729
|
case 11:
|
|
724
730
|
case "end":
|
|
725
|
-
return
|
|
731
|
+
return _context7.stop();
|
|
726
732
|
}
|
|
727
733
|
}
|
|
728
734
|
}, _callee2);
|