parse 8.4.0 → 8.5.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.
@@ -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.4.0",
21
+ VERSION: 'js' + "8.5.0-alpha.1",
22
22
  APPLICATION_ID: null,
23
23
  JAVASCRIPT_KEY: null,
24
24
  MAINTENANCE_KEY: null,
@@ -299,6 +299,10 @@ class ParseFile {
299
299
  * }
300
300
  * });
301
301
  * </pre>
302
+ * <li>maxUploadSize: Overrides the server's maxUploadSize for this upload.
303
+ * Requires the master key. Only supported for Buffer and Stream source
304
+ * types; files created from base64 strings, number arrays, Blobs, or URIs
305
+ * do not support this option. Requires Parse Server >= 9.5.0.
302
306
  * </ul>
303
307
  * @returns {Promise | undefined} Promise that is resolved when the save finishes.
304
308
  */
@@ -315,7 +319,7 @@ class ParseFile {
315
319
  throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
316
320
  }
317
321
  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)) {
322
+ if (controller.saveBinary && (this._source.format === 'stream' || !hasFileData || options.maxUploadSize)) {
319
323
  // Binary upload via ajax (file data sent via headers for streams)
320
324
  this._previousSave = controller.saveBinary(this._name, this._source, options).then(res => {
321
325
  this._name = res.name;
@@ -589,6 +593,9 @@ const DefaultController = {
589
593
  if (options.tags && (0, _keys.default)(options.tags).length > 0) {
590
594
  headers['X-Parse-File-Tags'] = (0, _stringify.default)(options.tags);
591
595
  }
596
+ if (options.maxUploadSize) {
597
+ headers['X-Parse-File-Max-Upload-Size'] = options.maxUploadSize.replace(/[\r\n]/g, '');
598
+ }
592
599
  const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
593
600
  if (jsKey) {
594
601
  headers['X-Parse-JavaScript-Key'] = jsKey;
@@ -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.4.0",
17
+ VERSION: 'js' + "8.5.0-alpha.1",
18
18
  APPLICATION_ID: null,
19
19
  JAVASCRIPT_KEY: null,
20
20
  MAINTENANCE_KEY: null,
@@ -258,6 +258,10 @@ class ParseFile {
258
258
  * }
259
259
  * });
260
260
  * </pre>
261
+ * <li>maxUploadSize: Overrides the server's maxUploadSize for this upload.
262
+ * Requires the master key. Only supported for Buffer and Stream source
263
+ * types; files created from base64 strings, number arrays, Blobs, or URIs
264
+ * do not support this option. Requires Parse Server >= 9.5.0.
261
265
  * </ul>
262
266
  * @returns {Promise | undefined} Promise that is resolved when the save finishes.
263
267
  */
@@ -274,7 +278,7 @@ class ParseFile {
274
278
  throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
275
279
  }
276
280
  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)) {
281
+ if (controller.saveBinary && (this._source.format === 'stream' || !hasFileData || options.maxUploadSize)) {
278
282
  // Binary upload via ajax (file data sent via headers for streams)
279
283
  this._previousSave = controller.saveBinary(this._name, this._source, options).then(res => {
280
284
  this._name = res.name;
@@ -548,6 +552,9 @@ const DefaultController = {
548
552
  if (options.tags && Object.keys(options.tags).length > 0) {
549
553
  headers['X-Parse-File-Tags'] = JSON.stringify(options.tags);
550
554
  }
555
+ if (options.maxUploadSize) {
556
+ headers['X-Parse-File-Max-Upload-Size'] = options.maxUploadSize.replace(/[\r\n]/g, '');
557
+ }
551
558
  const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
552
559
  if (jsKey) {
553
560
  headers['X-Parse-JavaScript-Key'] = jsKey;
@@ -10,7 +10,7 @@ var config = {
10
10
  SERVER_URL: 'https://api.parse.com/1',
11
11
  LIVEQUERY_SERVER_URL: null,
12
12
  ENCRYPTED_KEY: null,
13
- VERSION: 'js' + "8.4.0",
13
+ VERSION: 'js' + "8.5.0-alpha.1",
14
14
  APPLICATION_ID: null,
15
15
  JAVASCRIPT_KEY: null,
16
16
  MAINTENANCE_KEY: null,
@@ -169,7 +169,7 @@ var ParseFile = function () {
169
169
  throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
170
170
  }
171
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)) {
172
+ if (controller.saveBinary && (this._source.format === 'stream' || !hasFileData || options.maxUploadSize)) {
173
173
  this._previousSave = controller.saveBinary(this._name, this._source, options).then(function (res) {
174
174
  _this2._name = res.name;
175
175
  _this2._url = res.url;
@@ -420,6 +420,9 @@ var DefaultController = {
420
420
  if (options.tags && Object.keys(options.tags).length > 0) {
421
421
  headers['X-Parse-File-Tags'] = JSON.stringify(options.tags);
422
422
  }
423
+ if (options.maxUploadSize) {
424
+ headers['X-Parse-File-Max-Upload-Size'] = options.maxUploadSize.replace(/[\r\n]/g, '');
425
+ }
423
426
  var jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
424
427
  if (jsKey) {
425
428
  headers['X-Parse-JavaScript-Key'] = jsKey;
@@ -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.4.0",
21
+ VERSION: 'js' + "8.5.0-alpha.1",
22
22
  APPLICATION_ID: null,
23
23
  JAVASCRIPT_KEY: null,
24
24
  MAINTENANCE_KEY: null,
@@ -299,6 +299,10 @@ class ParseFile {
299
299
  * }
300
300
  * });
301
301
  * </pre>
302
+ * <li>maxUploadSize: Overrides the server's maxUploadSize for this upload.
303
+ * Requires the master key. Only supported for Buffer and Stream source
304
+ * types; files created from base64 strings, number arrays, Blobs, or URIs
305
+ * do not support this option. Requires Parse Server >= 9.5.0.
302
306
  * </ul>
303
307
  * @returns {Promise | undefined} Promise that is resolved when the save finishes.
304
308
  */
@@ -315,7 +319,7 @@ class ParseFile {
315
319
  throw new Error('Cannot save a stream-based file without saveBinary support on the FileController.');
316
320
  }
317
321
  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)) {
322
+ if (controller.saveBinary && (this._source.format === 'stream' || !hasFileData || options.maxUploadSize)) {
319
323
  // Binary upload via ajax (file data sent via headers for streams)
320
324
  this._previousSave = controller.saveBinary(this._name, this._source, options).then(res => {
321
325
  this._name = res.name;
@@ -589,6 +593,9 @@ const DefaultController = {
589
593
  if (options.tags && (0, _keys.default)(options.tags).length > 0) {
590
594
  headers['X-Parse-File-Tags'] = (0, _stringify.default)(options.tags);
591
595
  }
596
+ if (options.maxUploadSize) {
597
+ headers['X-Parse-File-Max-Upload-Size'] = options.maxUploadSize.replace(/[\r\n]/g, '');
598
+ }
592
599
  const jsKey = _CoreManager.default.get('JAVASCRIPT_KEY');
593
600
  if (jsKey) {
594
601
  headers['X-Parse-JavaScript-Key'] = jsKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parse",
3
- "version": "8.4.0",
3
+ "version": "8.5.0-alpha.1",
4
4
  "description": "Parse JavaScript SDK",
5
5
  "homepage": "https://parseplatform.org",
6
6
  "keywords": [
@@ -10,6 +10,17 @@ export type FileSaveOptions = FullOptions & {
10
10
  metadata?: Record<string, any>;
11
11
  tags?: Record<string, any>;
12
12
  directory?: string;
13
+ /**
14
+ * Overrides the server's `maxUploadSize` for this file upload. Requires the
15
+ * master key (`useMasterKey: true`). The value uses the same format as the
16
+ * server option (e.g. `'50mb'`, `'1gb'`).
17
+ *
18
+ * Only supported for Buffer and Stream source types. Files created from
19
+ * base64 strings, number arrays, Blobs, or URIs do not support this option.
20
+ *
21
+ * Requires Parse Server >= 9.5.0.
22
+ */
23
+ maxUploadSize?: string;
13
24
  };
14
25
  export type FileSource = {
15
26
  format: 'file';
@@ -171,6 +182,10 @@ declare class ParseFile {
171
182
  * }
172
183
  * });
173
184
  * </pre>
185
+ * <li>maxUploadSize: Overrides the server's maxUploadSize for this upload.
186
+ * Requires the master key. Only supported for Buffer and Stream source
187
+ * types; files created from base64 strings, number arrays, Blobs, or URIs
188
+ * do not support this option. Requires Parse Server >= 9.5.0.
174
189
  * </ul>
175
190
  * @returns {Promise | undefined} Promise that is resolved when the save finishes.
176
191
  */