parse 8.3.0-alpha.1 → 8.4.0-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 +23 -13
- package/dist/parse.min.js +1 -1
- package/dist/parse.weapp.js +23 -13
- package/dist/parse.weapp.min.js +1 -1
- package/lib/browser/CoreManager.js +1 -1
- package/lib/browser/ParseFile.js +24 -11
- package/lib/node/CoreManager.js +1 -1
- package/lib/node/ParseFile.js +23 -11
- package/lib/react-native/CoreManager.js +1 -1
- package/lib/react-native/ParseFile.js +11 -5
- package/lib/weapp/CoreManager.js +1 -1
- package/lib/weapp/ParseFile.js +24 -11
- package/package.json +1 -1
- package/types/ParseFile.d.ts +11 -5
|
@@ -18,7 +18,7 @@ const config = {
|
|
|
18
18
|
SERVER_URL: 'https://api.parse.com/1',
|
|
19
19
|
LIVEQUERY_SERVER_URL: null,
|
|
20
20
|
ENCRYPTED_KEY: null,
|
|
21
|
-
VERSION: 'js' + "8.
|
|
21
|
+
VERSION: 'js' + "8.4.0-alpha.1",
|
|
22
22
|
APPLICATION_ID: null,
|
|
23
23
|
JAVASCRIPT_KEY: null,
|
|
24
24
|
MAINTENANCE_KEY: null,
|
package/lib/browser/ParseFile.js
CHANGED
|
@@ -19,6 +19,7 @@ var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stab
|
|
|
19
19
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
20
20
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
21
21
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
22
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
22
23
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
23
24
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
24
25
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
@@ -86,7 +87,7 @@ class ParseFile {
|
|
|
86
87
|
* JSON encoding if metadata or tags are set.
|
|
87
88
|
* 6. (Node.js only) a Readable stream, or a Web ReadableStream.
|
|
88
89
|
* Streamed as raw binary data directly into the upload request.
|
|
89
|
-
*
|
|
90
|
+
* Supports metadata, tags, and directory when Parse Server >= 9.5.0.
|
|
90
91
|
* For example:
|
|
91
92
|
* <pre>
|
|
92
93
|
* var fileUploadControl = $("#profilePhotoFileUpload")[0];
|
|
@@ -264,6 +265,7 @@ class ParseFile {
|
|
|
264
265
|
|
|
265
266
|
/**
|
|
266
267
|
* Gets the directory of the file.
|
|
268
|
+
* Requires Parse Server >= 9.4.0.
|
|
267
269
|
*
|
|
268
270
|
* @returns {string | undefined}
|
|
269
271
|
*/
|
|
@@ -277,8 +279,8 @@ class ParseFile {
|
|
|
277
279
|
* In Node.js, files created with Buffer or ReadableStream are uploaded as
|
|
278
280
|
* raw binary data, avoiding base64 encoding overhead. If metadata
|
|
279
281
|
* or tags are set on a Buffer-backed file, the upload falls back to base64
|
|
280
|
-
* JSON encoding
|
|
281
|
-
*
|
|
282
|
+
* JSON encoding. Stream-backed files support metadata, tags, and directory
|
|
283
|
+
* when Parse Server >= 9.5.0.
|
|
282
284
|
*
|
|
283
285
|
* @param {object} options
|
|
284
286
|
* Valid options are:<ul>
|
|
@@ -309,15 +311,12 @@ class ParseFile {
|
|
|
309
311
|
const controller = _CoreManager.default.getFileController();
|
|
310
312
|
if (!this._previousSave) {
|
|
311
313
|
if (this._source.format === 'buffer' || this._source.format === 'stream') {
|
|
312
|
-
const hasFileData = this._metadata && (0, _keys.default)(this._metadata).length > 0 || this._tags && (0, _keys.default)(this._tags).length > 0 || !!this._directory;
|
|
313
|
-
if (this._source.format === 'stream' && hasFileData) {
|
|
314
|
-
throw new Error('Cannot save a stream-based file with metadata, tags, or directory. Use a Buffer instead.');
|
|
315
|
-
}
|
|
316
314
|
if (this._source.format === 'stream' && !controller.saveBinary) {
|
|
317
315
|
throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
|
|
318
316
|
}
|
|
319
|
-
|
|
320
|
-
|
|
317
|
+
const hasFileData = this._metadata && (0, _keys.default)(this._metadata).length > 0 || this._tags && (0, _keys.default)(this._tags).length > 0 || !!this._directory;
|
|
318
|
+
if (controller.saveBinary && (this._source.format === 'stream' || !hasFileData)) {
|
|
319
|
+
// Binary upload via ajax (file data sent via headers for streams)
|
|
321
320
|
this._previousSave = controller.saveBinary(this._name, this._source, options).then(res => {
|
|
322
321
|
this._name = res.name;
|
|
323
322
|
this._url = res.url;
|
|
@@ -436,7 +435,8 @@ class ParseFile {
|
|
|
436
435
|
}
|
|
437
436
|
|
|
438
437
|
/**
|
|
439
|
-
* Sets metadata to be saved with file object. Overwrites existing metadata
|
|
438
|
+
* Sets metadata to be saved with file object. Overwrites existing metadata.
|
|
439
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
440
440
|
*
|
|
441
441
|
* @param {object} metadata Key value pairs to be stored with file object
|
|
442
442
|
*/
|
|
@@ -451,6 +451,7 @@ class ParseFile {
|
|
|
451
451
|
|
|
452
452
|
/**
|
|
453
453
|
* Sets metadata to be saved with file object. Adds to existing metadata.
|
|
454
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
454
455
|
*
|
|
455
456
|
* @param {string} key key to store the metadata
|
|
456
457
|
* @param {*} value metadata
|
|
@@ -462,7 +463,8 @@ class ParseFile {
|
|
|
462
463
|
}
|
|
463
464
|
|
|
464
465
|
/**
|
|
465
|
-
* Sets tags to be saved with file object. Overwrites existing tags
|
|
466
|
+
* Sets tags to be saved with file object. Overwrites existing tags.
|
|
467
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
466
468
|
*
|
|
467
469
|
* @param {object} tags Key value pairs to be stored with file object
|
|
468
470
|
*/
|
|
@@ -477,6 +479,7 @@ class ParseFile {
|
|
|
477
479
|
|
|
478
480
|
/**
|
|
479
481
|
* Sets tags to be saved with file object. Adds to existing tags.
|
|
482
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
480
483
|
*
|
|
481
484
|
* @param {string} key key to store tags
|
|
482
485
|
* @param {*} value tag
|
|
@@ -490,6 +493,7 @@ class ParseFile {
|
|
|
490
493
|
/**
|
|
491
494
|
* Sets the directory where the file will be stored.
|
|
492
495
|
* Requires the Master Key when saving.
|
|
496
|
+
* Requires Parse Server >= 9.4.0; when used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
493
497
|
*
|
|
494
498
|
* @param {string} directory the directory path
|
|
495
499
|
*/
|
|
@@ -576,6 +580,15 @@ const DefaultController = {
|
|
|
576
580
|
'X-Parse-Upload-Mode': 'stream'
|
|
577
581
|
};
|
|
578
582
|
headers['Content-Type'] = (source.type || 'application/octet-stream').replace(/[\r\n]/g, '');
|
|
583
|
+
if (options.directory) {
|
|
584
|
+
headers['X-Parse-File-Directory'] = options.directory.replace(/[\r\n]/g, '');
|
|
585
|
+
}
|
|
586
|
+
if (options.metadata && (0, _keys.default)(options.metadata).length > 0) {
|
|
587
|
+
headers['X-Parse-File-Metadata'] = (0, _stringify.default)(options.metadata);
|
|
588
|
+
}
|
|
589
|
+
if (options.tags && (0, _keys.default)(options.tags).length > 0) {
|
|
590
|
+
headers['X-Parse-File-Tags'] = (0, _stringify.default)(options.tags);
|
|
591
|
+
}
|
|
579
592
|
const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
580
593
|
if (jsKey) {
|
|
581
594
|
headers['X-Parse-JavaScript-Key'] = jsKey;
|
package/lib/node/CoreManager.js
CHANGED
|
@@ -14,7 +14,7 @@ const config = {
|
|
|
14
14
|
SERVER_URL: 'https://api.parse.com/1',
|
|
15
15
|
LIVEQUERY_SERVER_URL: null,
|
|
16
16
|
ENCRYPTED_KEY: null,
|
|
17
|
-
VERSION: 'js' + "8.
|
|
17
|
+
VERSION: 'js' + "8.4.0-alpha.1",
|
|
18
18
|
APPLICATION_ID: null,
|
|
19
19
|
JAVASCRIPT_KEY: null,
|
|
20
20
|
MAINTENANCE_KEY: null,
|
package/lib/node/ParseFile.js
CHANGED
|
@@ -56,7 +56,7 @@ class ParseFile {
|
|
|
56
56
|
* JSON encoding if metadata or tags are set.
|
|
57
57
|
* 6. (Node.js only) a Readable stream, or a Web ReadableStream.
|
|
58
58
|
* Streamed as raw binary data directly into the upload request.
|
|
59
|
-
*
|
|
59
|
+
* Supports metadata, tags, and directory when Parse Server >= 9.5.0.
|
|
60
60
|
* For example:
|
|
61
61
|
* <pre>
|
|
62
62
|
* var fileUploadControl = $("#profilePhotoFileUpload")[0];
|
|
@@ -224,6 +224,7 @@ class ParseFile {
|
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
* Gets the directory of the file.
|
|
227
|
+
* Requires Parse Server >= 9.4.0.
|
|
227
228
|
*
|
|
228
229
|
* @returns {string | undefined}
|
|
229
230
|
*/
|
|
@@ -237,8 +238,8 @@ class ParseFile {
|
|
|
237
238
|
* In Node.js, files created with Buffer or ReadableStream are uploaded as
|
|
238
239
|
* raw binary data, avoiding base64 encoding overhead. If metadata
|
|
239
240
|
* or tags are set on a Buffer-backed file, the upload falls back to base64
|
|
240
|
-
* JSON encoding
|
|
241
|
-
*
|
|
241
|
+
* JSON encoding. Stream-backed files support metadata, tags, and directory
|
|
242
|
+
* when Parse Server >= 9.5.0.
|
|
242
243
|
*
|
|
243
244
|
* @param {object} options
|
|
244
245
|
* Valid options are:<ul>
|
|
@@ -269,15 +270,12 @@ class ParseFile {
|
|
|
269
270
|
const controller = _CoreManager.default.getFileController();
|
|
270
271
|
if (!this._previousSave) {
|
|
271
272
|
if (this._source.format === 'buffer' || this._source.format === 'stream') {
|
|
272
|
-
const hasFileData = this._metadata && Object.keys(this._metadata).length > 0 || this._tags && Object.keys(this._tags).length > 0 || !!this._directory;
|
|
273
|
-
if (this._source.format === 'stream' && hasFileData) {
|
|
274
|
-
throw new Error('Cannot save a stream-based file with metadata, tags, or directory. Use a Buffer instead.');
|
|
275
|
-
}
|
|
276
273
|
if (this._source.format === 'stream' && !controller.saveBinary) {
|
|
277
274
|
throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
|
|
278
275
|
}
|
|
279
|
-
|
|
280
|
-
|
|
276
|
+
const hasFileData = this._metadata && Object.keys(this._metadata).length > 0 || this._tags && Object.keys(this._tags).length > 0 || !!this._directory;
|
|
277
|
+
if (controller.saveBinary && (this._source.format === 'stream' || !hasFileData)) {
|
|
278
|
+
// Binary upload via ajax (file data sent via headers for streams)
|
|
281
279
|
this._previousSave = controller.saveBinary(this._name, this._source, options).then(res => {
|
|
282
280
|
this._name = res.name;
|
|
283
281
|
this._url = res.url;
|
|
@@ -395,7 +393,8 @@ class ParseFile {
|
|
|
395
393
|
}
|
|
396
394
|
|
|
397
395
|
/**
|
|
398
|
-
* Sets metadata to be saved with file object. Overwrites existing metadata
|
|
396
|
+
* Sets metadata to be saved with file object. Overwrites existing metadata.
|
|
397
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
399
398
|
*
|
|
400
399
|
* @param {object} metadata Key value pairs to be stored with file object
|
|
401
400
|
*/
|
|
@@ -409,6 +408,7 @@ class ParseFile {
|
|
|
409
408
|
|
|
410
409
|
/**
|
|
411
410
|
* Sets metadata to be saved with file object. Adds to existing metadata.
|
|
411
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
412
412
|
*
|
|
413
413
|
* @param {string} key key to store the metadata
|
|
414
414
|
* @param {*} value metadata
|
|
@@ -420,7 +420,8 @@ class ParseFile {
|
|
|
420
420
|
}
|
|
421
421
|
|
|
422
422
|
/**
|
|
423
|
-
* Sets tags to be saved with file object. Overwrites existing tags
|
|
423
|
+
* Sets tags to be saved with file object. Overwrites existing tags.
|
|
424
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
424
425
|
*
|
|
425
426
|
* @param {object} tags Key value pairs to be stored with file object
|
|
426
427
|
*/
|
|
@@ -434,6 +435,7 @@ class ParseFile {
|
|
|
434
435
|
|
|
435
436
|
/**
|
|
436
437
|
* Sets tags to be saved with file object. Adds to existing tags.
|
|
438
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
437
439
|
*
|
|
438
440
|
* @param {string} key key to store tags
|
|
439
441
|
* @param {*} value tag
|
|
@@ -447,6 +449,7 @@ class ParseFile {
|
|
|
447
449
|
/**
|
|
448
450
|
* Sets the directory where the file will be stored.
|
|
449
451
|
* Requires the Master Key when saving.
|
|
452
|
+
* Requires Parse Server >= 9.4.0; when used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
450
453
|
*
|
|
451
454
|
* @param {string} directory the directory path
|
|
452
455
|
*/
|
|
@@ -536,6 +539,15 @@ const DefaultController = {
|
|
|
536
539
|
'X-Parse-Upload-Mode': 'stream'
|
|
537
540
|
};
|
|
538
541
|
headers['Content-Type'] = (source.type || 'application/octet-stream').replace(/[\r\n]/g, '');
|
|
542
|
+
if (options.directory) {
|
|
543
|
+
headers['X-Parse-File-Directory'] = options.directory.replace(/[\r\n]/g, '');
|
|
544
|
+
}
|
|
545
|
+
if (options.metadata && Object.keys(options.metadata).length > 0) {
|
|
546
|
+
headers['X-Parse-File-Metadata'] = JSON.stringify(options.metadata);
|
|
547
|
+
}
|
|
548
|
+
if (options.tags && Object.keys(options.tags).length > 0) {
|
|
549
|
+
headers['X-Parse-File-Tags'] = JSON.stringify(options.tags);
|
|
550
|
+
}
|
|
539
551
|
const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
540
552
|
if (jsKey) {
|
|
541
553
|
headers['X-Parse-JavaScript-Key'] = jsKey;
|
|
@@ -165,14 +165,11 @@ var ParseFile = function () {
|
|
|
165
165
|
var controller = _CoreManager.default.getFileController();
|
|
166
166
|
if (!this._previousSave) {
|
|
167
167
|
if (this._source.format === 'buffer' || this._source.format === 'stream') {
|
|
168
|
-
var hasFileData = this._metadata && Object.keys(this._metadata).length > 0 || this._tags && Object.keys(this._tags).length > 0 || !!this._directory;
|
|
169
|
-
if (this._source.format === 'stream' && hasFileData) {
|
|
170
|
-
throw new Error('Cannot save a stream-based file with metadata, tags, or directory. Use a Buffer instead.');
|
|
171
|
-
}
|
|
172
168
|
if (this._source.format === 'stream' && !controller.saveBinary) {
|
|
173
169
|
throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
|
|
174
170
|
}
|
|
175
|
-
|
|
171
|
+
var hasFileData = this._metadata && Object.keys(this._metadata).length > 0 || this._tags && Object.keys(this._tags).length > 0 || !!this._directory;
|
|
172
|
+
if (controller.saveBinary && (this._source.format === 'stream' || !hasFileData)) {
|
|
176
173
|
this._previousSave = controller.saveBinary(this._name, this._source, options).then(function (res) {
|
|
177
174
|
_this2._name = res.name;
|
|
178
175
|
_this2._url = res.url;
|
|
@@ -414,6 +411,15 @@ var DefaultController = {
|
|
|
414
411
|
'X-Parse-Upload-Mode': 'stream'
|
|
415
412
|
};
|
|
416
413
|
headers['Content-Type'] = (source.type || 'application/octet-stream').replace(/[\r\n]/g, '');
|
|
414
|
+
if (options.directory) {
|
|
415
|
+
headers['X-Parse-File-Directory'] = options.directory.replace(/[\r\n]/g, '');
|
|
416
|
+
}
|
|
417
|
+
if (options.metadata && Object.keys(options.metadata).length > 0) {
|
|
418
|
+
headers['X-Parse-File-Metadata'] = JSON.stringify(options.metadata);
|
|
419
|
+
}
|
|
420
|
+
if (options.tags && Object.keys(options.tags).length > 0) {
|
|
421
|
+
headers['X-Parse-File-Tags'] = JSON.stringify(options.tags);
|
|
422
|
+
}
|
|
417
423
|
var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
418
424
|
if (jsKey) {
|
|
419
425
|
headers['X-Parse-JavaScript-Key'] = jsKey;
|
package/lib/weapp/CoreManager.js
CHANGED
|
@@ -18,7 +18,7 @@ const config = {
|
|
|
18
18
|
SERVER_URL: 'https://api.parse.com/1',
|
|
19
19
|
LIVEQUERY_SERVER_URL: null,
|
|
20
20
|
ENCRYPTED_KEY: null,
|
|
21
|
-
VERSION: 'js' + "8.
|
|
21
|
+
VERSION: 'js' + "8.4.0-alpha.1",
|
|
22
22
|
APPLICATION_ID: null,
|
|
23
23
|
JAVASCRIPT_KEY: null,
|
|
24
24
|
MAINTENANCE_KEY: null,
|
package/lib/weapp/ParseFile.js
CHANGED
|
@@ -19,6 +19,7 @@ var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stab
|
|
|
19
19
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
20
20
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
21
21
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
22
|
+
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
|
|
22
23
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
23
24
|
var _CoreManager = _interopRequireDefault(require("./CoreManager"));
|
|
24
25
|
var _ParseError = _interopRequireDefault(require("./ParseError"));
|
|
@@ -86,7 +87,7 @@ class ParseFile {
|
|
|
86
87
|
* JSON encoding if metadata or tags are set.
|
|
87
88
|
* 6. (Node.js only) a Readable stream, or a Web ReadableStream.
|
|
88
89
|
* Streamed as raw binary data directly into the upload request.
|
|
89
|
-
*
|
|
90
|
+
* Supports metadata, tags, and directory when Parse Server >= 9.5.0.
|
|
90
91
|
* For example:
|
|
91
92
|
* <pre>
|
|
92
93
|
* var fileUploadControl = $("#profilePhotoFileUpload")[0];
|
|
@@ -264,6 +265,7 @@ class ParseFile {
|
|
|
264
265
|
|
|
265
266
|
/**
|
|
266
267
|
* Gets the directory of the file.
|
|
268
|
+
* Requires Parse Server >= 9.4.0.
|
|
267
269
|
*
|
|
268
270
|
* @returns {string | undefined}
|
|
269
271
|
*/
|
|
@@ -277,8 +279,8 @@ class ParseFile {
|
|
|
277
279
|
* In Node.js, files created with Buffer or ReadableStream are uploaded as
|
|
278
280
|
* raw binary data, avoiding base64 encoding overhead. If metadata
|
|
279
281
|
* or tags are set on a Buffer-backed file, the upload falls back to base64
|
|
280
|
-
* JSON encoding
|
|
281
|
-
*
|
|
282
|
+
* JSON encoding. Stream-backed files support metadata, tags, and directory
|
|
283
|
+
* when Parse Server >= 9.5.0.
|
|
282
284
|
*
|
|
283
285
|
* @param {object} options
|
|
284
286
|
* Valid options are:<ul>
|
|
@@ -309,15 +311,12 @@ class ParseFile {
|
|
|
309
311
|
const controller = _CoreManager.default.getFileController();
|
|
310
312
|
if (!this._previousSave) {
|
|
311
313
|
if (this._source.format === 'buffer' || this._source.format === 'stream') {
|
|
312
|
-
const hasFileData = this._metadata && (0, _keys.default)(this._metadata).length > 0 || this._tags && (0, _keys.default)(this._tags).length > 0 || !!this._directory;
|
|
313
|
-
if (this._source.format === 'stream' && hasFileData) {
|
|
314
|
-
throw new Error('Cannot save a stream-based file with metadata, tags, or directory. Use a Buffer instead.');
|
|
315
|
-
}
|
|
316
314
|
if (this._source.format === 'stream' && !controller.saveBinary) {
|
|
317
315
|
throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
|
|
318
316
|
}
|
|
319
|
-
|
|
320
|
-
|
|
317
|
+
const hasFileData = this._metadata && (0, _keys.default)(this._metadata).length > 0 || this._tags && (0, _keys.default)(this._tags).length > 0 || !!this._directory;
|
|
318
|
+
if (controller.saveBinary && (this._source.format === 'stream' || !hasFileData)) {
|
|
319
|
+
// Binary upload via ajax (file data sent via headers for streams)
|
|
321
320
|
this._previousSave = controller.saveBinary(this._name, this._source, options).then(res => {
|
|
322
321
|
this._name = res.name;
|
|
323
322
|
this._url = res.url;
|
|
@@ -436,7 +435,8 @@ class ParseFile {
|
|
|
436
435
|
}
|
|
437
436
|
|
|
438
437
|
/**
|
|
439
|
-
* Sets metadata to be saved with file object. Overwrites existing metadata
|
|
438
|
+
* Sets metadata to be saved with file object. Overwrites existing metadata.
|
|
439
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
440
440
|
*
|
|
441
441
|
* @param {object} metadata Key value pairs to be stored with file object
|
|
442
442
|
*/
|
|
@@ -451,6 +451,7 @@ class ParseFile {
|
|
|
451
451
|
|
|
452
452
|
/**
|
|
453
453
|
* Sets metadata to be saved with file object. Adds to existing metadata.
|
|
454
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
454
455
|
*
|
|
455
456
|
* @param {string} key key to store the metadata
|
|
456
457
|
* @param {*} value metadata
|
|
@@ -462,7 +463,8 @@ class ParseFile {
|
|
|
462
463
|
}
|
|
463
464
|
|
|
464
465
|
/**
|
|
465
|
-
* Sets tags to be saved with file object. Overwrites existing tags
|
|
466
|
+
* Sets tags to be saved with file object. Overwrites existing tags.
|
|
467
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
466
468
|
*
|
|
467
469
|
* @param {object} tags Key value pairs to be stored with file object
|
|
468
470
|
*/
|
|
@@ -477,6 +479,7 @@ class ParseFile {
|
|
|
477
479
|
|
|
478
480
|
/**
|
|
479
481
|
* Sets tags to be saved with file object. Adds to existing tags.
|
|
482
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
480
483
|
*
|
|
481
484
|
* @param {string} key key to store tags
|
|
482
485
|
* @param {*} value tag
|
|
@@ -490,6 +493,7 @@ class ParseFile {
|
|
|
490
493
|
/**
|
|
491
494
|
* Sets the directory where the file will be stored.
|
|
492
495
|
* Requires the Master Key when saving.
|
|
496
|
+
* Requires Parse Server >= 9.4.0; when used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
493
497
|
*
|
|
494
498
|
* @param {string} directory the directory path
|
|
495
499
|
*/
|
|
@@ -576,6 +580,15 @@ const DefaultController = {
|
|
|
576
580
|
'X-Parse-Upload-Mode': 'stream'
|
|
577
581
|
};
|
|
578
582
|
headers['Content-Type'] = (source.type || 'application/octet-stream').replace(/[\r\n]/g, '');
|
|
583
|
+
if (options.directory) {
|
|
584
|
+
headers['X-Parse-File-Directory'] = options.directory.replace(/[\r\n]/g, '');
|
|
585
|
+
}
|
|
586
|
+
if (options.metadata && (0, _keys.default)(options.metadata).length > 0) {
|
|
587
|
+
headers['X-Parse-File-Metadata'] = (0, _stringify.default)(options.metadata);
|
|
588
|
+
}
|
|
589
|
+
if (options.tags && (0, _keys.default)(options.tags).length > 0) {
|
|
590
|
+
headers['X-Parse-File-Tags'] = (0, _stringify.default)(options.tags);
|
|
591
|
+
}
|
|
579
592
|
const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
580
593
|
if (jsKey) {
|
|
581
594
|
headers['X-Parse-JavaScript-Key'] = jsKey;
|
package/package.json
CHANGED
package/types/ParseFile.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ declare class ParseFile {
|
|
|
64
64
|
* JSON encoding if metadata or tags are set.
|
|
65
65
|
* 6. (Node.js only) a Readable stream, or a Web ReadableStream.
|
|
66
66
|
* Streamed as raw binary data directly into the upload request.
|
|
67
|
-
*
|
|
67
|
+
* Supports metadata, tags, and directory when Parse Server >= 9.5.0.
|
|
68
68
|
* For example:
|
|
69
69
|
* <pre>
|
|
70
70
|
* var fileUploadControl = $("#profilePhotoFileUpload")[0];
|
|
@@ -140,6 +140,7 @@ declare class ParseFile {
|
|
|
140
140
|
tags(): Record<string, any>;
|
|
141
141
|
/**
|
|
142
142
|
* Gets the directory of the file.
|
|
143
|
+
* Requires Parse Server >= 9.4.0.
|
|
143
144
|
*
|
|
144
145
|
* @returns {string | undefined}
|
|
145
146
|
*/
|
|
@@ -150,8 +151,8 @@ declare class ParseFile {
|
|
|
150
151
|
* In Node.js, files created with Buffer or ReadableStream are uploaded as
|
|
151
152
|
* raw binary data, avoiding base64 encoding overhead. If metadata
|
|
152
153
|
* or tags are set on a Buffer-backed file, the upload falls back to base64
|
|
153
|
-
* JSON encoding
|
|
154
|
-
*
|
|
154
|
+
* JSON encoding. Stream-backed files support metadata, tags, and directory
|
|
155
|
+
* when Parse Server >= 9.5.0.
|
|
155
156
|
*
|
|
156
157
|
* @param {object} options
|
|
157
158
|
* Valid options are:<ul>
|
|
@@ -199,26 +200,30 @@ declare class ParseFile {
|
|
|
199
200
|
};
|
|
200
201
|
equals(other: any): boolean;
|
|
201
202
|
/**
|
|
202
|
-
* Sets metadata to be saved with file object. Overwrites existing metadata
|
|
203
|
+
* Sets metadata to be saved with file object. Overwrites existing metadata.
|
|
204
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
203
205
|
*
|
|
204
206
|
* @param {object} metadata Key value pairs to be stored with file object
|
|
205
207
|
*/
|
|
206
208
|
setMetadata(metadata: Record<string, any>): void;
|
|
207
209
|
/**
|
|
208
210
|
* Sets metadata to be saved with file object. Adds to existing metadata.
|
|
211
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
209
212
|
*
|
|
210
213
|
* @param {string} key key to store the metadata
|
|
211
214
|
* @param {*} value metadata
|
|
212
215
|
*/
|
|
213
216
|
addMetadata(key: string, value: any): void;
|
|
214
217
|
/**
|
|
215
|
-
* Sets tags to be saved with file object. Overwrites existing tags
|
|
218
|
+
* Sets tags to be saved with file object. Overwrites existing tags.
|
|
219
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
216
220
|
*
|
|
217
221
|
* @param {object} tags Key value pairs to be stored with file object
|
|
218
222
|
*/
|
|
219
223
|
setTags(tags: Record<string, any>): void;
|
|
220
224
|
/**
|
|
221
225
|
* Sets tags to be saved with file object. Adds to existing tags.
|
|
226
|
+
* When used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
222
227
|
*
|
|
223
228
|
* @param {string} key key to store tags
|
|
224
229
|
* @param {*} value tag
|
|
@@ -227,6 +232,7 @@ declare class ParseFile {
|
|
|
227
232
|
/**
|
|
228
233
|
* Sets the directory where the file will be stored.
|
|
229
234
|
* Requires the Master Key when saving.
|
|
235
|
+
* Requires Parse Server >= 9.4.0; when used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
230
236
|
*
|
|
231
237
|
* @param {string} directory the directory path
|
|
232
238
|
*/
|