@atlaskit/media-client 36.1.0 → 36.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/media-client
2
2
 
3
+ ## 36.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`21abd28a7966a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/21abd28a7966a) -
8
+ Adds x-expected-size header to multipart chunk uploads to prevent corrupted file entries in the
9
+ object store.
10
+
11
+ ## 36.1.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [`71ee114498663`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/71ee114498663) -
16
+ Parameterized anonymize media file names on upload
17
+
3
18
  ## 36.1.0
4
19
 
5
20
  ### Minor Changes
@@ -545,7 +545,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
545
545
  }, {
546
546
  key: "uploadExternal",
547
547
  value: function () {
548
- var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(url, collection, traceContext) {
548
+ var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(url, collection, traceContext, anonymizeFilename) {
549
549
  var _this3 = this;
550
550
  var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
551
551
  return _regenerator.default.wrap(function _callee0$(_context0) {
@@ -582,11 +582,11 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
582
582
  }
583
583
  }, _callee8);
584
584
  }));
585
- return function (_x17, _x18) {
585
+ return function (_x18, _x19) {
586
586
  return _ref0.apply(this, arguments);
587
587
  };
588
588
  }());
589
- name = (0, _platformFeatureFlags.fg)('platform_media_upload_external_anonymize_filename') ? crypto.randomUUID() : url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
589
+ name = anonymizeFilename && (0, _platformFeatureFlags.fg)('platform_media_upload_external_anonymize_filename') ? crypto.randomUUID() : url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
590
590
  fileState = {
591
591
  status: 'processing',
592
592
  name: name,
@@ -662,7 +662,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
662
662
  }
663
663
  }, _callee9, null, [[10, 16]]);
664
664
  }));
665
- return function (_x19, _x20) {
665
+ return function (_x20, _x21) {
666
666
  return _ref1.apply(this, arguments);
667
667
  };
668
668
  }()));
@@ -672,7 +672,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
672
672
  }
673
673
  }, _callee0, this);
674
674
  }));
675
- function uploadExternal(_x14, _x15, _x16) {
675
+ function uploadExternal(_x14, _x15, _x16, _x17) {
676
676
  return _uploadExternal.apply(this, arguments);
677
677
  }
678
678
  return uploadExternal;
@@ -774,7 +774,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
774
774
  }
775
775
  }, _callee1, this);
776
776
  }));
777
- function downloadBinary(_x21) {
777
+ function downloadBinary(_x22) {
778
778
  return _downloadBinary.apply(this, arguments);
779
779
  }
780
780
  return downloadBinary;
@@ -817,7 +817,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
817
817
  }
818
818
  }, _callee10, this);
819
819
  }));
820
- function registerCopyIntent(_x22, _x23) {
820
+ function registerCopyIntent(_x23, _x24) {
821
821
  return _registerCopyIntent.apply(this, arguments);
822
822
  }
823
823
  return registerCopyIntent;
@@ -867,7 +867,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
867
867
  }
868
868
  }, _callee11);
869
869
  }));
870
- function copyFileWithToken(_x24, _x25, _x26) {
870
+ function copyFileWithToken(_x25, _x26, _x27) {
871
871
  return _copyFileWithToken.apply(this, arguments);
872
872
  }
873
873
  return copyFileWithToken;
@@ -896,7 +896,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
896
896
  }
897
897
  }, _callee12, this);
898
898
  }));
899
- function copyFileWithIntent(_x27, _x28, _x29) {
899
+ function copyFileWithIntent(_x28, _x29, _x30) {
900
900
  return _copyFileWithIntent.apply(this, arguments);
901
901
  }
902
902
  return copyFileWithIntent;
@@ -1047,7 +1047,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
1047
1047
  }
1048
1048
  }, _callee13, this, [[6, 40]]);
1049
1049
  }));
1050
- function copyFile(_x30, _x31) {
1050
+ function copyFile(_x31, _x32) {
1051
1051
  return _copyFile.apply(this, arguments);
1052
1052
  }
1053
1053
  return copyFile;
@@ -840,8 +840,8 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
840
840
  }, {
841
841
  key: "appendChunksToUpload",
842
842
  value: function () {
843
- var _appendChunksToUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(uploadId, body, collectionName, traceContext) {
844
- var metadata, options;
843
+ var _appendChunksToUpload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(uploadId, body, collectionName, traceContext, options) {
844
+ var metadata, headers, requestOptions;
845
845
  return _regenerator.default.wrap(function _callee15$(_context15) {
846
846
  while (1) switch (_context15.prev = _context15.next) {
847
847
  case 0:
@@ -849,23 +849,27 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
849
849
  method: 'PUT',
850
850
  endpoint: '/upload/{uploadId}/chunks'
851
851
  };
852
- options = _objectSpread(_objectSpread({}, metadata), {}, {
852
+ headers = _objectSpread({}, jsonHeaders);
853
+ if ((options === null || options === void 0 ? void 0 : options.expectedFileSize) !== undefined && (0, _platformFeatureFlags.fg)('platform_media_upload_expected_size_header')) {
854
+ headers['x-expected-size'] = options.expectedFileSize.toString();
855
+ }
856
+ requestOptions = _objectSpread(_objectSpread({}, metadata), {}, {
853
857
  authContext: {
854
858
  collectionName: collectionName
855
859
  },
856
- headers: jsonHeaders,
860
+ headers: headers,
857
861
  body: JSON.stringify(body),
858
862
  traceContext: traceContext
859
863
  });
860
- _context15.next = 4;
861
- return this.request("/upload/".concat(uploadId, "/chunks"), options);
862
- case 4:
864
+ _context15.next = 6;
865
+ return this.request("/upload/".concat(uploadId, "/chunks"), requestOptions);
866
+ case 6:
863
867
  case "end":
864
868
  return _context15.stop();
865
869
  }
866
870
  }, _callee15, this);
867
871
  }));
868
- function appendChunksToUpload(_x51, _x52, _x53, _x54) {
872
+ function appendChunksToUpload(_x51, _x52, _x53, _x54, _x55) {
869
873
  return _appendChunksToUpload.apply(this, arguments);
870
874
  }
871
875
  return appendChunksToUpload;
@@ -948,7 +952,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
948
952
  }
949
953
  }, _callee16, this);
950
954
  }));
951
- function registerCopyIntents(_x55, _x56, _x57) {
955
+ function registerCopyIntents(_x56, _x57, _x58) {
952
956
  return _registerCopyIntents.apply(this, arguments);
953
957
  }
954
958
  return registerCopyIntents;
@@ -1036,7 +1040,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
1036
1040
  }
1037
1041
  }, _callee17, this);
1038
1042
  }));
1039
- function request(_x58) {
1043
+ function request(_x59) {
1040
1044
  return _request2.apply(this, arguments);
1041
1045
  }
1042
1046
  return request;
@@ -1069,7 +1073,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
1069
1073
  }
1070
1074
  }, _callee18);
1071
1075
  }));
1072
- function testUrl(_x59) {
1076
+ function testUrl(_x60) {
1073
1077
  return _testUrl.apply(this, arguments);
1074
1078
  }
1075
1079
  return testUrl;
@@ -68,7 +68,7 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
68
68
  };
69
69
  }();
70
70
  };
71
- var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext) {
71
+ var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext, size) {
72
72
  var offset = 0;
73
73
  return /*#__PURE__*/function () {
74
74
  var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(chunks) {
@@ -86,11 +86,14 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
86
86
  };
87
87
  _context3.t3 = collection;
88
88
  _context3.t4 = traceContext;
89
- _context3.next = 9;
90
- return _context3.t0.appendChunksToUpload.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4);
91
- case 9:
92
- offset += chunks.length;
89
+ _context3.t5 = {
90
+ expectedFileSize: size
91
+ };
92
+ _context3.next = 10;
93
+ return _context3.t0.appendChunksToUpload.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4, _context3.t5);
93
94
  case 10:
95
+ offset += chunks.length;
96
+ case 11:
94
97
  case "end":
95
98
  return _context3.stop();
96
99
  }
@@ -170,7 +173,7 @@ var uploadFile = exports.uploadFile = function uploadFile(file, store, uploadabl
170
173
  uploadingConcurrency: 3,
171
174
  uploadingFunction: createUploadingFunction(store, deferredUploadId, collection, traceContext),
172
175
  processingBatchSize: _constants.PROCESSING_BATCH_SIZE,
173
- processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext)
176
+ processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext, file.size)
174
177
  }, {
175
178
  onProgress: function onProgress(progress) {
176
179
  if (callbacks) {
@@ -341,7 +341,7 @@ export class FileFetcherImpl {
341
341
  deferredUploadId
342
342
  };
343
343
  }
344
- async uploadExternal(url, collection, traceContext) {
344
+ async uploadExternal(url, collection, traceContext, anonymizeFilename) {
345
345
  const uploadableFileUpfrontIds = this.generateUploadableFileUpfrontIds(collection, traceContext);
346
346
  const {
347
347
  id,
@@ -359,7 +359,7 @@ export class FileFetcherImpl {
359
359
  origin: 'remote'
360
360
  });
361
361
  });
362
- const name = fg('platform_media_upload_external_anonymize_filename') ? crypto.randomUUID() : url.split('/').pop() || '';
362
+ const name = anonymizeFilename && fg('platform_media_upload_external_anonymize_filename') ? crypto.randomUUID() : url.split('/').pop() || '';
363
363
  // we create a initial fileState with the minimum info that we have at this point
364
364
  const fileState = {
365
365
  status: 'processing',
@@ -523,21 +523,27 @@ export class MediaStore {
523
523
  };
524
524
  return this.request(`/file/${id}/document/${endpoint}`, requestOptions).then(createMapResponseToBlob(metadata));
525
525
  }
526
- async appendChunksToUpload(uploadId, body, collectionName, traceContext) {
526
+ async appendChunksToUpload(uploadId, body, collectionName, traceContext, options) {
527
527
  const metadata = {
528
528
  method: 'PUT',
529
529
  endpoint: '/upload/{uploadId}/chunks'
530
530
  };
531
- const options = {
531
+ const headers = {
532
+ ...jsonHeaders
533
+ };
534
+ if ((options === null || options === void 0 ? void 0 : options.expectedFileSize) !== undefined && fg('platform_media_upload_expected_size_header')) {
535
+ headers['x-expected-size'] = options.expectedFileSize.toString();
536
+ }
537
+ const requestOptions = {
532
538
  ...metadata,
533
539
  authContext: {
534
540
  collectionName
535
541
  },
536
- headers: jsonHeaders,
542
+ headers,
537
543
  body: JSON.stringify(body),
538
544
  traceContext
539
545
  };
540
- await this.request(`/upload/${uploadId}/chunks`, options);
546
+ await this.request(`/upload/${uploadId}/chunks`, requestOptions);
541
547
  }
542
548
  copyFileWithToken(body, params, traceContext) {
543
549
  const metadata = {
@@ -15,13 +15,15 @@ const hashingFunction = async (blob, hashAlgorithm) => {
15
15
  const createUploadingFunction = (store, deferredUploadId, collectionName, traceContext) => async chunk => {
16
16
  return await store.uploadChunk(chunk.hash, chunk.blob, await deferredUploadId, chunk.partNumber, collectionName, traceContext);
17
17
  };
18
- const createProcessingFunction = (store, deferredUploadId, collection, traceContext) => {
18
+ const createProcessingFunction = (store, deferredUploadId, collection, traceContext, size) => {
19
19
  let offset = 0;
20
20
  return async chunks => {
21
21
  await store.appendChunksToUpload(await deferredUploadId, {
22
22
  chunks: hashedChunks(chunks),
23
23
  offset
24
- }, collection, traceContext);
24
+ }, collection, traceContext, {
25
+ expectedFileSize: size
26
+ });
25
27
  offset += chunks.length;
26
28
  };
27
29
  };
@@ -89,7 +91,7 @@ export const uploadFile = (file, store, uploadableFileUpfrontIds, callbacks, tra
89
91
  uploadingConcurrency: 3,
90
92
  uploadingFunction: createUploadingFunction(store, deferredUploadId, collection, traceContext),
91
93
  processingBatchSize: PROCESSING_BATCH_SIZE,
92
- processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext)
94
+ processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext, file.size)
93
95
  }, {
94
96
  onProgress(progress) {
95
97
  if (callbacks) {
@@ -528,7 +528,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
528
528
  }, {
529
529
  key: "uploadExternal",
530
530
  value: function () {
531
- var _uploadExternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(url, collection, traceContext) {
531
+ var _uploadExternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(url, collection, traceContext, anonymizeFilename) {
532
532
  var _this3 = this;
533
533
  var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
534
534
  return _regeneratorRuntime.wrap(function _callee0$(_context0) {
@@ -565,11 +565,11 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
565
565
  }
566
566
  }, _callee8);
567
567
  }));
568
- return function (_x17, _x18) {
568
+ return function (_x18, _x19) {
569
569
  return _ref0.apply(this, arguments);
570
570
  };
571
571
  }());
572
- name = fg('platform_media_upload_external_anonymize_filename') ? crypto.randomUUID() : url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
572
+ name = anonymizeFilename && fg('platform_media_upload_external_anonymize_filename') ? crypto.randomUUID() : url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
573
573
  fileState = {
574
574
  status: 'processing',
575
575
  name: name,
@@ -645,7 +645,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
645
645
  }
646
646
  }, _callee9, null, [[10, 16]]);
647
647
  }));
648
- return function (_x19, _x20) {
648
+ return function (_x20, _x21) {
649
649
  return _ref1.apply(this, arguments);
650
650
  };
651
651
  }()));
@@ -655,7 +655,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
655
655
  }
656
656
  }, _callee0, this);
657
657
  }));
658
- function uploadExternal(_x14, _x15, _x16) {
658
+ function uploadExternal(_x14, _x15, _x16, _x17) {
659
659
  return _uploadExternal.apply(this, arguments);
660
660
  }
661
661
  return uploadExternal;
@@ -757,7 +757,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
757
757
  }
758
758
  }, _callee1, this);
759
759
  }));
760
- function downloadBinary(_x21) {
760
+ function downloadBinary(_x22) {
761
761
  return _downloadBinary.apply(this, arguments);
762
762
  }
763
763
  return downloadBinary;
@@ -800,7 +800,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
800
800
  }
801
801
  }, _callee10, this);
802
802
  }));
803
- function registerCopyIntent(_x22, _x23) {
803
+ function registerCopyIntent(_x23, _x24) {
804
804
  return _registerCopyIntent.apply(this, arguments);
805
805
  }
806
806
  return registerCopyIntent;
@@ -850,7 +850,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
850
850
  }
851
851
  }, _callee11);
852
852
  }));
853
- function copyFileWithToken(_x24, _x25, _x26) {
853
+ function copyFileWithToken(_x25, _x26, _x27) {
854
854
  return _copyFileWithToken.apply(this, arguments);
855
855
  }
856
856
  return copyFileWithToken;
@@ -879,7 +879,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
879
879
  }
880
880
  }, _callee12, this);
881
881
  }));
882
- function copyFileWithIntent(_x27, _x28, _x29) {
882
+ function copyFileWithIntent(_x28, _x29, _x30) {
883
883
  return _copyFileWithIntent.apply(this, arguments);
884
884
  }
885
885
  return copyFileWithIntent;
@@ -1030,7 +1030,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
1030
1030
  }
1031
1031
  }, _callee13, this, [[6, 40]]);
1032
1032
  }));
1033
- function copyFile(_x30, _x31) {
1033
+ function copyFile(_x31, _x32) {
1034
1034
  return _copyFile.apply(this, arguments);
1035
1035
  }
1036
1036
  return copyFile;
@@ -834,8 +834,8 @@ export var MediaStore = /*#__PURE__*/function () {
834
834
  }, {
835
835
  key: "appendChunksToUpload",
836
836
  value: function () {
837
- var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(uploadId, body, collectionName, traceContext) {
838
- var metadata, options;
837
+ var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(uploadId, body, collectionName, traceContext, options) {
838
+ var metadata, headers, requestOptions;
839
839
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
840
840
  while (1) switch (_context15.prev = _context15.next) {
841
841
  case 0:
@@ -843,23 +843,27 @@ export var MediaStore = /*#__PURE__*/function () {
843
843
  method: 'PUT',
844
844
  endpoint: '/upload/{uploadId}/chunks'
845
845
  };
846
- options = _objectSpread(_objectSpread({}, metadata), {}, {
846
+ headers = _objectSpread({}, jsonHeaders);
847
+ if ((options === null || options === void 0 ? void 0 : options.expectedFileSize) !== undefined && fg('platform_media_upload_expected_size_header')) {
848
+ headers['x-expected-size'] = options.expectedFileSize.toString();
849
+ }
850
+ requestOptions = _objectSpread(_objectSpread({}, metadata), {}, {
847
851
  authContext: {
848
852
  collectionName: collectionName
849
853
  },
850
- headers: jsonHeaders,
854
+ headers: headers,
851
855
  body: JSON.stringify(body),
852
856
  traceContext: traceContext
853
857
  });
854
- _context15.next = 4;
855
- return this.request("/upload/".concat(uploadId, "/chunks"), options);
856
- case 4:
858
+ _context15.next = 6;
859
+ return this.request("/upload/".concat(uploadId, "/chunks"), requestOptions);
860
+ case 6:
857
861
  case "end":
858
862
  return _context15.stop();
859
863
  }
860
864
  }, _callee15, this);
861
865
  }));
862
- function appendChunksToUpload(_x51, _x52, _x53, _x54) {
866
+ function appendChunksToUpload(_x51, _x52, _x53, _x54, _x55) {
863
867
  return _appendChunksToUpload.apply(this, arguments);
864
868
  }
865
869
  return appendChunksToUpload;
@@ -942,7 +946,7 @@ export var MediaStore = /*#__PURE__*/function () {
942
946
  }
943
947
  }, _callee16, this);
944
948
  }));
945
- function registerCopyIntents(_x55, _x56, _x57) {
949
+ function registerCopyIntents(_x56, _x57, _x58) {
946
950
  return _registerCopyIntents.apply(this, arguments);
947
951
  }
948
952
  return registerCopyIntents;
@@ -1030,7 +1034,7 @@ export var MediaStore = /*#__PURE__*/function () {
1030
1034
  }
1031
1035
  }, _callee17, this);
1032
1036
  }));
1033
- function request(_x58) {
1037
+ function request(_x59) {
1034
1038
  return _request2.apply(this, arguments);
1035
1039
  }
1036
1040
  return request;
@@ -1063,7 +1067,7 @@ export var MediaStore = /*#__PURE__*/function () {
1063
1067
  }
1064
1068
  }, _callee18);
1065
1069
  }));
1066
- function testUrl(_x59) {
1070
+ function testUrl(_x60) {
1067
1071
  return _testUrl.apply(this, arguments);
1068
1072
  }
1069
1073
  return testUrl;
@@ -62,7 +62,7 @@ var createUploadingFunction = function createUploadingFunction(store, deferredUp
62
62
  };
63
63
  }();
64
64
  };
65
- var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext) {
65
+ var createProcessingFunction = function createProcessingFunction(store, deferredUploadId, collection, traceContext, size) {
66
66
  var offset = 0;
67
67
  return /*#__PURE__*/function () {
68
68
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chunks) {
@@ -80,11 +80,14 @@ var createProcessingFunction = function createProcessingFunction(store, deferred
80
80
  };
81
81
  _context3.t3 = collection;
82
82
  _context3.t4 = traceContext;
83
- _context3.next = 9;
84
- return _context3.t0.appendChunksToUpload.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4);
85
- case 9:
86
- offset += chunks.length;
83
+ _context3.t5 = {
84
+ expectedFileSize: size
85
+ };
86
+ _context3.next = 10;
87
+ return _context3.t0.appendChunksToUpload.call(_context3.t0, _context3.t1, _context3.t2, _context3.t3, _context3.t4, _context3.t5);
87
88
  case 10:
89
+ offset += chunks.length;
90
+ case 11:
88
91
  case "end":
89
92
  return _context3.stop();
90
93
  }
@@ -164,7 +167,7 @@ export var uploadFile = function uploadFile(file, store, uploadableFileUpfrontId
164
167
  uploadingConcurrency: 3,
165
168
  uploadingFunction: createUploadingFunction(store, deferredUploadId, collection, traceContext),
166
169
  processingBatchSize: PROCESSING_BATCH_SIZE,
167
- processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext)
170
+ processingFunction: createProcessingFunction(store, deferredUploadId, collection, traceContext, file.size)
168
171
  }, {
169
172
  onProgress: function onProgress(progress) {
170
173
  if (callbacks) {
@@ -36,7 +36,7 @@ export interface FileFetcher {
36
36
  getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
37
37
  touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
38
38
  upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
39
- uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
39
+ uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext, anonymizeFilename?: boolean): Promise<ExternalUploadPayload>;
40
40
  downloadBinary(id: string, name?: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
41
41
  getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
42
42
  copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
@@ -67,7 +67,7 @@ export declare class FileFetcherImpl implements FileFetcher {
67
67
  private createDownloadFileStream;
68
68
  touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
69
69
  private generateUploadableFileUpfrontIds;
70
- uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
70
+ uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext, anonymizeFilename?: boolean): Promise<ExternalUploadPayload>;
71
71
  private getUploadingFileStateBase;
72
72
  upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
73
73
  downloadBinary(id: string, name?: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
@@ -35,7 +35,9 @@ export declare class MediaStore implements MediaApi {
35
35
  }>;
36
36
  getDocumentContent(id: string, options: GetDocumentContentOptions, traceContext?: MediaTraceContext): Promise<DocumentPageRangeContent>;
37
37
  getDocumentPageImage(id: string, options: GetDocumentPageImage, traceContext?: MediaTraceContext): Promise<Blob>;
38
- appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
38
+ appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext, options?: {
39
+ expectedFileSize?: number;
40
+ }): Promise<void>;
39
41
  copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
40
42
  copyFile(id: string, params: CopyFileParams, traceContext?: MediaTraceContext, clientId?: string): Promise<MediaStoreResponse<MediaFile>>;
41
43
  registerCopyIntents(files: Array<{
@@ -185,7 +185,9 @@ export interface MediaApi {
185
185
  getImageMetadata: (id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<{
186
186
  metadata: ImageMetadata;
187
187
  }>;
188
- appendChunksToUpload: (uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext) => Promise<void>;
188
+ appendChunksToUpload: (uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext, options?: {
189
+ expectedFileSize?: number;
190
+ }) => Promise<void>;
189
191
  copyFileWithToken: (body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext) => Promise<MediaStoreResponse<MediaFile>>;
190
192
  copyFile: (id: string, params: CopyFileParams) => Promise<MediaStoreResponse<MediaFile>>;
191
193
  registerCopyIntents: (files: Array<{
@@ -36,7 +36,7 @@ export interface FileFetcher {
36
36
  getArtifactURL(artifacts: MediaFileArtifacts, artifactName: keyof MediaFileArtifacts, collectionName?: string): Promise<string>;
37
37
  touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
38
38
  upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
39
- uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
39
+ uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext, anonymizeFilename?: boolean): Promise<ExternalUploadPayload>;
40
40
  downloadBinary(id: string, name?: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
41
41
  getCurrentState(id: string, options?: GetFileOptions): Promise<FileState>;
42
42
  copyFile(source: CopySourceFile, destination: CopyDestination, options?: CopyFileOptions, traceContext?: MediaTraceContext): Promise<MediaFile>;
@@ -67,7 +67,7 @@ export declare class FileFetcherImpl implements FileFetcher {
67
67
  private createDownloadFileStream;
68
68
  touchFiles(descriptors: TouchFileDescriptor[], collection?: string, traceContext?: MediaTraceContext): Promise<TouchedFiles>;
69
69
  private generateUploadableFileUpfrontIds;
70
- uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext): Promise<ExternalUploadPayload>;
70
+ uploadExternal(url: string, collection?: string, traceContext?: MediaTraceContext, anonymizeFilename?: boolean): Promise<ExternalUploadPayload>;
71
71
  private getUploadingFileStateBase;
72
72
  upload(file: UploadableFile, controller?: UploadController, uploadableFileUpfrontIds?: UploadableFileUpfrontIds, traceContext?: MediaTraceContext): MediaSubscribable;
73
73
  downloadBinary(id: string, name?: string, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
@@ -35,7 +35,9 @@ export declare class MediaStore implements MediaApi {
35
35
  }>;
36
36
  getDocumentContent(id: string, options: GetDocumentContentOptions, traceContext?: MediaTraceContext): Promise<DocumentPageRangeContent>;
37
37
  getDocumentPageImage(id: string, options: GetDocumentPageImage, traceContext?: MediaTraceContext): Promise<Blob>;
38
- appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
38
+ appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext, options?: {
39
+ expectedFileSize?: number;
40
+ }): Promise<void>;
39
41
  copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
40
42
  copyFile(id: string, params: CopyFileParams, traceContext?: MediaTraceContext, clientId?: string): Promise<MediaStoreResponse<MediaFile>>;
41
43
  registerCopyIntents(files: Array<{
@@ -185,7 +185,9 @@ export interface MediaApi {
185
185
  getImageMetadata: (id: string, params?: MediaStoreGetFileImageParams, traceContext?: MediaTraceContext) => Promise<{
186
186
  metadata: ImageMetadata;
187
187
  }>;
188
- appendChunksToUpload: (uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext) => Promise<void>;
188
+ appendChunksToUpload: (uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext, options?: {
189
+ expectedFileSize?: number;
190
+ }) => Promise<void>;
189
191
  copyFileWithToken: (body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext) => Promise<MediaStoreResponse<MediaFile>>;
190
192
  copyFile: (id: string, params: CopyFileParams) => Promise<MediaStoreResponse<MediaFile>>;
191
193
  registerCopyIntents: (files: Array<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "36.1.0",
3
+ "version": "36.2.0",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@atlaskit/atlassian-context": "^0.8.0",
33
33
  "@atlaskit/chunkinator": "^7.1.0",
34
- "@atlaskit/media-common": "^13.2.0",
34
+ "@atlaskit/media-common": "^13.3.0",
35
35
  "@atlaskit/platform-feature-flags": "^1.1.0",
36
36
  "@babel/runtime": "^7.0.0",
37
37
  "dataloader": "^2.1.0",
@@ -95,6 +95,9 @@
95
95
  },
96
96
  "confluence_watermark_admin_ui": {
97
97
  "type": "boolean"
98
+ },
99
+ "platform_media_upload_expected_size_header": {
100
+ "type": "boolean"
98
101
  }
99
102
  }
100
103
  }