parse 8.3.0 → 8.4.0
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 +22 -14
- package/dist/parse.min.js +1 -1
- package/dist/parse.weapp.js +22 -14
- package/dist/parse.weapp.min.js +1 -1
- package/lib/browser/CoreManager.js +1 -1
- package/lib/browser/ParseFile.js +23 -12
- package/lib/node/CoreManager.js +1 -1
- package/lib/node/ParseFile.js +22 -12
- 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 +23 -12
- package/package.json +1 -1
- package/types/ParseFile.d.ts +10 -6
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];
|
|
@@ -278,8 +279,8 @@ class ParseFile {
|
|
|
278
279
|
* In Node.js, files created with Buffer or ReadableStream are uploaded as
|
|
279
280
|
* raw binary data, avoiding base64 encoding overhead. If metadata
|
|
280
281
|
* or tags are set on a Buffer-backed file, the upload falls back to base64
|
|
281
|
-
* JSON encoding
|
|
282
|
-
*
|
|
282
|
+
* JSON encoding. Stream-backed files support metadata, tags, and directory
|
|
283
|
+
* when Parse Server >= 9.5.0.
|
|
283
284
|
*
|
|
284
285
|
* @param {object} options
|
|
285
286
|
* Valid options are:<ul>
|
|
@@ -310,15 +311,12 @@ class ParseFile {
|
|
|
310
311
|
const controller = _CoreManager.default.getFileController();
|
|
311
312
|
if (!this._previousSave) {
|
|
312
313
|
if (this._source.format === 'buffer' || this._source.format === 'stream') {
|
|
313
|
-
const hasFileData = this._metadata && (0, _keys.default)(this._metadata).length > 0 || this._tags && (0, _keys.default)(this._tags).length > 0 || !!this._directory;
|
|
314
|
-
if (this._source.format === 'stream' && hasFileData) {
|
|
315
|
-
throw new Error('Cannot save a stream-based file with metadata, tags, or directory. Use a Buffer instead.');
|
|
316
|
-
}
|
|
317
314
|
if (this._source.format === 'stream' && !controller.saveBinary) {
|
|
318
315
|
throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
|
|
319
316
|
}
|
|
320
|
-
|
|
321
|
-
|
|
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)
|
|
322
320
|
this._previousSave = controller.saveBinary(this._name, this._source, options).then(res => {
|
|
323
321
|
this._name = res.name;
|
|
324
322
|
this._url = res.url;
|
|
@@ -437,7 +435,8 @@ class ParseFile {
|
|
|
437
435
|
}
|
|
438
436
|
|
|
439
437
|
/**
|
|
440
|
-
* 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.
|
|
441
440
|
*
|
|
442
441
|
* @param {object} metadata Key value pairs to be stored with file object
|
|
443
442
|
*/
|
|
@@ -452,6 +451,7 @@ class ParseFile {
|
|
|
452
451
|
|
|
453
452
|
/**
|
|
454
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.
|
|
455
455
|
*
|
|
456
456
|
* @param {string} key key to store the metadata
|
|
457
457
|
* @param {*} value metadata
|
|
@@ -463,7 +463,8 @@ class ParseFile {
|
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
/**
|
|
466
|
-
* 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.
|
|
467
468
|
*
|
|
468
469
|
* @param {object} tags Key value pairs to be stored with file object
|
|
469
470
|
*/
|
|
@@ -478,6 +479,7 @@ class ParseFile {
|
|
|
478
479
|
|
|
479
480
|
/**
|
|
480
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.
|
|
481
483
|
*
|
|
482
484
|
* @param {string} key key to store tags
|
|
483
485
|
* @param {*} value tag
|
|
@@ -491,7 +493,7 @@ class ParseFile {
|
|
|
491
493
|
/**
|
|
492
494
|
* Sets the directory where the file will be stored.
|
|
493
495
|
* Requires the Master Key when saving.
|
|
494
|
-
* Requires Parse Server >= 9.4.0.
|
|
496
|
+
* Requires Parse Server >= 9.4.0; when used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
495
497
|
*
|
|
496
498
|
* @param {string} directory the directory path
|
|
497
499
|
*/
|
|
@@ -578,6 +580,15 @@ const DefaultController = {
|
|
|
578
580
|
'X-Parse-Upload-Mode': 'stream'
|
|
579
581
|
};
|
|
580
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
|
+
}
|
|
581
592
|
const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
582
593
|
if (jsKey) {
|
|
583
594
|
headers['X-Parse-JavaScript-Key'] = jsKey;
|
package/lib/node/CoreManager.js
CHANGED
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];
|
|
@@ -238,8 +238,8 @@ class ParseFile {
|
|
|
238
238
|
* In Node.js, files created with Buffer or ReadableStream are uploaded as
|
|
239
239
|
* raw binary data, avoiding base64 encoding overhead. If metadata
|
|
240
240
|
* or tags are set on a Buffer-backed file, the upload falls back to base64
|
|
241
|
-
* JSON encoding
|
|
242
|
-
*
|
|
241
|
+
* JSON encoding. Stream-backed files support metadata, tags, and directory
|
|
242
|
+
* when Parse Server >= 9.5.0.
|
|
243
243
|
*
|
|
244
244
|
* @param {object} options
|
|
245
245
|
* Valid options are:<ul>
|
|
@@ -270,15 +270,12 @@ class ParseFile {
|
|
|
270
270
|
const controller = _CoreManager.default.getFileController();
|
|
271
271
|
if (!this._previousSave) {
|
|
272
272
|
if (this._source.format === 'buffer' || this._source.format === 'stream') {
|
|
273
|
-
const hasFileData = this._metadata && Object.keys(this._metadata).length > 0 || this._tags && Object.keys(this._tags).length > 0 || !!this._directory;
|
|
274
|
-
if (this._source.format === 'stream' && hasFileData) {
|
|
275
|
-
throw new Error('Cannot save a stream-based file with metadata, tags, or directory. Use a Buffer instead.');
|
|
276
|
-
}
|
|
277
273
|
if (this._source.format === 'stream' && !controller.saveBinary) {
|
|
278
274
|
throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
|
|
279
275
|
}
|
|
280
|
-
|
|
281
|
-
|
|
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)
|
|
282
279
|
this._previousSave = controller.saveBinary(this._name, this._source, options).then(res => {
|
|
283
280
|
this._name = res.name;
|
|
284
281
|
this._url = res.url;
|
|
@@ -396,7 +393,8 @@ class ParseFile {
|
|
|
396
393
|
}
|
|
397
394
|
|
|
398
395
|
/**
|
|
399
|
-
* 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.
|
|
400
398
|
*
|
|
401
399
|
* @param {object} metadata Key value pairs to be stored with file object
|
|
402
400
|
*/
|
|
@@ -410,6 +408,7 @@ class ParseFile {
|
|
|
410
408
|
|
|
411
409
|
/**
|
|
412
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.
|
|
413
412
|
*
|
|
414
413
|
* @param {string} key key to store the metadata
|
|
415
414
|
* @param {*} value metadata
|
|
@@ -421,7 +420,8 @@ class ParseFile {
|
|
|
421
420
|
}
|
|
422
421
|
|
|
423
422
|
/**
|
|
424
|
-
* 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.
|
|
425
425
|
*
|
|
426
426
|
* @param {object} tags Key value pairs to be stored with file object
|
|
427
427
|
*/
|
|
@@ -435,6 +435,7 @@ class ParseFile {
|
|
|
435
435
|
|
|
436
436
|
/**
|
|
437
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.
|
|
438
439
|
*
|
|
439
440
|
* @param {string} key key to store tags
|
|
440
441
|
* @param {*} value tag
|
|
@@ -448,7 +449,7 @@ class ParseFile {
|
|
|
448
449
|
/**
|
|
449
450
|
* Sets the directory where the file will be stored.
|
|
450
451
|
* Requires the Master Key when saving.
|
|
451
|
-
* Requires Parse Server >= 9.4.0.
|
|
452
|
+
* Requires Parse Server >= 9.4.0; when used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
452
453
|
*
|
|
453
454
|
* @param {string} directory the directory path
|
|
454
455
|
*/
|
|
@@ -538,6 +539,15 @@ const DefaultController = {
|
|
|
538
539
|
'X-Parse-Upload-Mode': 'stream'
|
|
539
540
|
};
|
|
540
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
|
+
}
|
|
541
551
|
const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
542
552
|
if (jsKey) {
|
|
543
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
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];
|
|
@@ -278,8 +279,8 @@ class ParseFile {
|
|
|
278
279
|
* In Node.js, files created with Buffer or ReadableStream are uploaded as
|
|
279
280
|
* raw binary data, avoiding base64 encoding overhead. If metadata
|
|
280
281
|
* or tags are set on a Buffer-backed file, the upload falls back to base64
|
|
281
|
-
* JSON encoding
|
|
282
|
-
*
|
|
282
|
+
* JSON encoding. Stream-backed files support metadata, tags, and directory
|
|
283
|
+
* when Parse Server >= 9.5.0.
|
|
283
284
|
*
|
|
284
285
|
* @param {object} options
|
|
285
286
|
* Valid options are:<ul>
|
|
@@ -310,15 +311,12 @@ class ParseFile {
|
|
|
310
311
|
const controller = _CoreManager.default.getFileController();
|
|
311
312
|
if (!this._previousSave) {
|
|
312
313
|
if (this._source.format === 'buffer' || this._source.format === 'stream') {
|
|
313
|
-
const hasFileData = this._metadata && (0, _keys.default)(this._metadata).length > 0 || this._tags && (0, _keys.default)(this._tags).length > 0 || !!this._directory;
|
|
314
|
-
if (this._source.format === 'stream' && hasFileData) {
|
|
315
|
-
throw new Error('Cannot save a stream-based file with metadata, tags, or directory. Use a Buffer instead.');
|
|
316
|
-
}
|
|
317
314
|
if (this._source.format === 'stream' && !controller.saveBinary) {
|
|
318
315
|
throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
|
|
319
316
|
}
|
|
320
|
-
|
|
321
|
-
|
|
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)
|
|
322
320
|
this._previousSave = controller.saveBinary(this._name, this._source, options).then(res => {
|
|
323
321
|
this._name = res.name;
|
|
324
322
|
this._url = res.url;
|
|
@@ -437,7 +435,8 @@ class ParseFile {
|
|
|
437
435
|
}
|
|
438
436
|
|
|
439
437
|
/**
|
|
440
|
-
* 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.
|
|
441
440
|
*
|
|
442
441
|
* @param {object} metadata Key value pairs to be stored with file object
|
|
443
442
|
*/
|
|
@@ -452,6 +451,7 @@ class ParseFile {
|
|
|
452
451
|
|
|
453
452
|
/**
|
|
454
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.
|
|
455
455
|
*
|
|
456
456
|
* @param {string} key key to store the metadata
|
|
457
457
|
* @param {*} value metadata
|
|
@@ -463,7 +463,8 @@ class ParseFile {
|
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
/**
|
|
466
|
-
* 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.
|
|
467
468
|
*
|
|
468
469
|
* @param {object} tags Key value pairs to be stored with file object
|
|
469
470
|
*/
|
|
@@ -478,6 +479,7 @@ class ParseFile {
|
|
|
478
479
|
|
|
479
480
|
/**
|
|
480
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.
|
|
481
483
|
*
|
|
482
484
|
* @param {string} key key to store tags
|
|
483
485
|
* @param {*} value tag
|
|
@@ -491,7 +493,7 @@ class ParseFile {
|
|
|
491
493
|
/**
|
|
492
494
|
* Sets the directory where the file will be stored.
|
|
493
495
|
* Requires the Master Key when saving.
|
|
494
|
-
* Requires Parse Server >= 9.4.0.
|
|
496
|
+
* Requires Parse Server >= 9.4.0; when used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
495
497
|
*
|
|
496
498
|
* @param {string} directory the directory path
|
|
497
499
|
*/
|
|
@@ -578,6 +580,15 @@ const DefaultController = {
|
|
|
578
580
|
'X-Parse-Upload-Mode': 'stream'
|
|
579
581
|
};
|
|
580
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
|
+
}
|
|
581
592
|
const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
|
|
582
593
|
if (jsKey) {
|
|
583
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];
|
|
@@ -151,8 +151,8 @@ declare class ParseFile {
|
|
|
151
151
|
* In Node.js, files created with Buffer or ReadableStream are uploaded as
|
|
152
152
|
* raw binary data, avoiding base64 encoding overhead. If metadata
|
|
153
153
|
* or tags are set on a Buffer-backed file, the upload falls back to base64
|
|
154
|
-
* JSON encoding
|
|
155
|
-
*
|
|
154
|
+
* JSON encoding. Stream-backed files support metadata, tags, and directory
|
|
155
|
+
* when Parse Server >= 9.5.0.
|
|
156
156
|
*
|
|
157
157
|
* @param {object} options
|
|
158
158
|
* Valid options are:<ul>
|
|
@@ -200,26 +200,30 @@ declare class ParseFile {
|
|
|
200
200
|
};
|
|
201
201
|
equals(other: any): boolean;
|
|
202
202
|
/**
|
|
203
|
-
* 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.
|
|
204
205
|
*
|
|
205
206
|
* @param {object} metadata Key value pairs to be stored with file object
|
|
206
207
|
*/
|
|
207
208
|
setMetadata(metadata: Record<string, any>): void;
|
|
208
209
|
/**
|
|
209
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.
|
|
210
212
|
*
|
|
211
213
|
* @param {string} key key to store the metadata
|
|
212
214
|
* @param {*} value metadata
|
|
213
215
|
*/
|
|
214
216
|
addMetadata(key: string, value: any): void;
|
|
215
217
|
/**
|
|
216
|
-
* 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.
|
|
217
220
|
*
|
|
218
221
|
* @param {object} tags Key value pairs to be stored with file object
|
|
219
222
|
*/
|
|
220
223
|
setTags(tags: Record<string, any>): void;
|
|
221
224
|
/**
|
|
222
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.
|
|
223
227
|
*
|
|
224
228
|
* @param {string} key key to store tags
|
|
225
229
|
* @param {*} value tag
|
|
@@ -228,7 +232,7 @@ declare class ParseFile {
|
|
|
228
232
|
/**
|
|
229
233
|
* Sets the directory where the file will be stored.
|
|
230
234
|
* Requires the Master Key when saving.
|
|
231
|
-
* Requires Parse Server >= 9.4.0.
|
|
235
|
+
* Requires Parse Server >= 9.4.0; when used with a stream-based file, requires Parse Server >= 9.5.0.
|
|
232
236
|
*
|
|
233
237
|
* @param {string} directory the directory path
|
|
234
238
|
*/
|