@atlaskit/media-client 15.1.1 → 17.0.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 +48 -0
- package/constants/package.json +1 -0
- package/dist/cjs/client/file-fetcher/index.js +0 -2
- package/dist/cjs/client/media-store/index.js +63 -24
- package/dist/cjs/constants.js +11 -2
- package/dist/cjs/index.js +12 -6
- package/dist/cjs/models/media.js +10 -2
- package/dist/cjs/uploader/calculateChunkSize.js +45 -0
- package/dist/cjs/uploader/error.js +67 -0
- package/dist/cjs/{uploader.js → uploader/index.js} +43 -8
- package/dist/cjs/utils/request/errors.js +4 -0
- package/dist/cjs/utils/request/helpers.js +40 -34
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/client/media-store/index.js +37 -9
- package/dist/es2019/constants.js +5 -1
- package/dist/es2019/index.js +2 -2
- package/dist/es2019/models/media.js +8 -1
- package/dist/es2019/uploader/calculateChunkSize.js +32 -0
- package/dist/es2019/uploader/error.js +30 -0
- package/dist/es2019/{uploader.js → uploader/index.js} +39 -8
- package/dist/es2019/utils/request/errors.js +4 -0
- package/dist/es2019/utils/request/helpers.js +22 -24
- package/dist/es2019/version.json +1 -1
- package/dist/esm/client/file-fetcher/index.js +0 -2
- package/dist/esm/client/media-store/index.js +57 -24
- package/dist/esm/constants.js +5 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/models/media.js +8 -1
- package/dist/esm/uploader/calculateChunkSize.js +32 -0
- package/dist/esm/uploader/error.js +51 -0
- package/dist/esm/{uploader.js → uploader/index.js} +39 -8
- package/dist/esm/utils/request/errors.js +4 -0
- package/dist/esm/utils/request/helpers.js +36 -31
- package/dist/esm/version.json +1 -1
- package/dist/types/client/media-store/index.d.ts +11 -2
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/models/errors/types.d.ts +1 -1
- package/dist/types/models/media.d.ts +5 -0
- package/dist/types/uploader/calculateChunkSize.d.ts +11 -0
- package/dist/types/uploader/error.d.ts +29 -0
- package/dist/types/{uploader.d.ts → uploader/index.d.ts} +1 -1
- package/dist/types/utils/request/errors.d.ts +2 -0
- package/dist/types/utils/request/helpers.d.ts +4 -4
- package/dist/types/utils/request/types.d.ts +2 -0
- package/package.json +7 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 17.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`a718050239e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a718050239e) - Media Client Uploader enforces a hard limit of 2Tb files.
|
|
8
|
+
|
|
9
|
+
To mitigate these changes:
|
|
10
|
+
|
|
11
|
+
- Set the feature flag mediaUploadApiV2 as false or Revert to a previous version for affected consumers and methods;
|
|
12
|
+
Media Client uploadFile method.
|
|
13
|
+
Media Client File Fetcher upload method.
|
|
14
|
+
Media Picker.
|
|
15
|
+
|
|
16
|
+
- [`e4d0b89cd8b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e4d0b89cd8b) - Additional parameters and changes to the way parameters are passed to MediaStore.uploadChunk and MediaStore.probeChunks.
|
|
17
|
+
- [`d07442a7ff7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d07442a7ff7) - Breaking change to media-client uploadFile method, chunkSize and processingBatchSize as parameters removed from uploadFile.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [`61cf857a95a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/61cf857a95a) - A util function for dynamically calculating chunkSizes.
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
24
|
+
## 16.0.1
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- [`12d0af77572`](https://bitbucket.org/atlassian/atlassian-frontend/commits/12d0af77572) - Store media environment in session storage
|
|
29
|
+
- [`325e210e59f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/325e210e59f) - Revert changes made in MEX-1638-revert-update-media-store-class-with-new-endpoint-parameters
|
|
30
|
+
- [`b73f20ed703`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b73f20ed703) - EDM-3073: Fix collab for media inline and copy-paste regression
|
|
31
|
+
- [`c2ede50a80a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c2ede50a80a) - Add media region and environment returned from media API response into failed analytic events.
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
|
|
34
|
+
## 16.0.0
|
|
35
|
+
|
|
36
|
+
### Major Changes
|
|
37
|
+
|
|
38
|
+
- [`b6d47de3fd9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b6d47de3fd9) - [MEX-1417] remove access to media file streams cache
|
|
39
|
+
|
|
40
|
+
### Minor Changes
|
|
41
|
+
|
|
42
|
+
- [`5e249d1ad05`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5e249d1ad05) - Exposed media environment
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- [`bde94d1a336`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bde94d1a336) - When chunkinator has multiple processing batches of chunks, file will only be finalised uploading for once.
|
|
47
|
+
- [`567b33b2eeb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/567b33b2eeb) - stripe out null and undefined params when calling media server
|
|
48
|
+
- [`c4c75f5a769`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c4c75f5a769) - Removed query string from media client
|
|
49
|
+
- Updated dependencies
|
|
50
|
+
|
|
3
51
|
## 15.1.1
|
|
4
52
|
|
|
5
53
|
### Patch Changes
|
package/constants/package.json
CHANGED
|
@@ -333,7 +333,6 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
333
333
|
};
|
|
334
334
|
mediaType = (0, _mediaTypeUtils.getMediaTypeFromMimeType)(type); // we emit a richer state after the blob is fetched
|
|
335
335
|
|
|
336
|
-
// we emit a richer state after the blob is fetched
|
|
337
336
|
subject.next({
|
|
338
337
|
status: 'processing',
|
|
339
338
|
name: name,
|
|
@@ -345,7 +344,6 @@ var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
345
344
|
preview: preview
|
|
346
345
|
}); // we don't want to wait for the file to be upload
|
|
347
346
|
|
|
348
|
-
// we don't want to wait for the file to be upload
|
|
349
347
|
_this3.upload(file, undefined, uploadableFileUpfrontIds);
|
|
350
348
|
|
|
351
349
|
_context3.next = 12;
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "MediaStoreError", {
|
|
|
12
12
|
return _error.MediaStoreError;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
+
exports.getMediaRegion = exports.getMediaEnvironment = void 0;
|
|
15
16
|
Object.defineProperty(exports, "isMediaStoreError", {
|
|
16
17
|
enumerable: true,
|
|
17
18
|
get: function get() {
|
|
@@ -45,6 +46,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
45
46
|
|
|
46
47
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
47
48
|
|
|
49
|
+
var MEDIA_API_REGION = 'media-api-region';
|
|
50
|
+
var MEDIA_API_ENVIRONMENT = 'media-api-environment';
|
|
48
51
|
var defaultImageOptions = {
|
|
49
52
|
'max-age': _constants.FILE_CACHE_MAX_AGE,
|
|
50
53
|
allowAnimated: true,
|
|
@@ -222,26 +225,38 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
222
225
|
}, {
|
|
223
226
|
key: "uploadChunk",
|
|
224
227
|
value: function () {
|
|
225
|
-
var _uploadChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(etag, blob
|
|
226
|
-
var
|
|
228
|
+
var _uploadChunk = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(etag, blob) {
|
|
229
|
+
var _ref,
|
|
230
|
+
collectionName,
|
|
231
|
+
uploadId,
|
|
232
|
+
partNumber,
|
|
233
|
+
metadata,
|
|
234
|
+
options,
|
|
235
|
+
_args3 = arguments;
|
|
236
|
+
|
|
227
237
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
228
238
|
while (1) {
|
|
229
239
|
switch (_context3.prev = _context3.next) {
|
|
230
240
|
case 0:
|
|
241
|
+
_ref = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : {}, collectionName = _ref.collectionName, uploadId = _ref.uploadId, partNumber = _ref.partNumber;
|
|
231
242
|
metadata = {
|
|
232
243
|
method: 'PUT',
|
|
233
244
|
endpoint: '/chunk/{etag}'
|
|
234
245
|
};
|
|
235
246
|
options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
247
|
+
params: {
|
|
248
|
+
uploadId: uploadId,
|
|
249
|
+
partNumber: partNumber
|
|
250
|
+
},
|
|
236
251
|
authContext: {
|
|
237
252
|
collectionName: collectionName
|
|
238
253
|
},
|
|
239
254
|
body: blob
|
|
240
255
|
});
|
|
241
|
-
_context3.next =
|
|
256
|
+
_context3.next = 5;
|
|
242
257
|
return this.request("/chunk/".concat(etag), options);
|
|
243
258
|
|
|
244
|
-
case
|
|
259
|
+
case 5:
|
|
245
260
|
case "end":
|
|
246
261
|
return _context3.stop();
|
|
247
262
|
}
|
|
@@ -249,7 +264,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
249
264
|
}, _callee3, this);
|
|
250
265
|
}));
|
|
251
266
|
|
|
252
|
-
function uploadChunk(_x6, _x7
|
|
267
|
+
function uploadChunk(_x6, _x7) {
|
|
253
268
|
return _uploadChunk.apply(this, arguments);
|
|
254
269
|
}
|
|
255
270
|
|
|
@@ -257,13 +272,20 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
257
272
|
}()
|
|
258
273
|
}, {
|
|
259
274
|
key: "probeChunks",
|
|
260
|
-
value: function probeChunks(chunks
|
|
275
|
+
value: function probeChunks(chunks) {
|
|
276
|
+
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
277
|
+
collectionName = _ref2.collectionName,
|
|
278
|
+
uploadId = _ref2.uploadId;
|
|
279
|
+
|
|
261
280
|
var metadata = {
|
|
262
281
|
method: 'POST',
|
|
263
282
|
endpoint: '/chunk/probe'
|
|
264
283
|
};
|
|
265
284
|
|
|
266
285
|
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
286
|
+
params: {
|
|
287
|
+
uploadId: uploadId
|
|
288
|
+
},
|
|
267
289
|
authContext: {
|
|
268
290
|
collectionName: collectionName
|
|
269
291
|
},
|
|
@@ -336,13 +358,13 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
336
358
|
key: "getFileImageURL",
|
|
337
359
|
value: function () {
|
|
338
360
|
var _getFileImageURL = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id, params) {
|
|
339
|
-
var
|
|
361
|
+
var _ref3, collectionName, auth;
|
|
340
362
|
|
|
341
363
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
342
364
|
while (1) {
|
|
343
365
|
switch (_context4.prev = _context4.next) {
|
|
344
366
|
case 0:
|
|
345
|
-
|
|
367
|
+
_ref3 = params || {}, collectionName = _ref3.collection;
|
|
346
368
|
_context4.next = 3;
|
|
347
369
|
return this.resolveAuth({
|
|
348
370
|
collectionName: collectionName
|
|
@@ -360,7 +382,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
360
382
|
}, _callee4, this);
|
|
361
383
|
}));
|
|
362
384
|
|
|
363
|
-
function getFileImageURL(
|
|
385
|
+
function getFileImageURL(_x8, _x9) {
|
|
364
386
|
return _getFileImageURL.apply(this, arguments);
|
|
365
387
|
}
|
|
366
388
|
|
|
@@ -415,7 +437,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
415
437
|
}, _callee5, this);
|
|
416
438
|
}));
|
|
417
439
|
|
|
418
|
-
function getFileBinaryURL(
|
|
440
|
+
function getFileBinaryURL(_x10, _x11) {
|
|
419
441
|
return _getFileBinaryURL.apply(this, arguments);
|
|
420
442
|
}
|
|
421
443
|
|
|
@@ -464,7 +486,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
464
486
|
}, _callee6, this);
|
|
465
487
|
}));
|
|
466
488
|
|
|
467
|
-
function getArtifactURL(_x13, _x14
|
|
489
|
+
function getArtifactURL(_x12, _x13, _x14) {
|
|
468
490
|
return _getArtifactURL.apply(this, arguments);
|
|
469
491
|
}
|
|
470
492
|
|
|
@@ -509,7 +531,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
509
531
|
}, _callee7, this);
|
|
510
532
|
}));
|
|
511
533
|
|
|
512
|
-
function getImage(_x16, _x17, _x18
|
|
534
|
+
function getImage(_x15, _x16, _x17, _x18) {
|
|
513
535
|
return _getImage.apply(this, arguments);
|
|
514
536
|
}
|
|
515
537
|
|
|
@@ -554,7 +576,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
554
576
|
}, _callee8, this);
|
|
555
577
|
}));
|
|
556
578
|
|
|
557
|
-
function getItems(
|
|
579
|
+
function getItems(_x19, _x20) {
|
|
558
580
|
return _getItems.apply(this, arguments);
|
|
559
581
|
}
|
|
560
582
|
|
|
@@ -589,7 +611,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
589
611
|
}, _callee9, this);
|
|
590
612
|
}));
|
|
591
613
|
|
|
592
|
-
function getImageMetadata(
|
|
614
|
+
function getImageMetadata(_x21, _x22) {
|
|
593
615
|
return _getImageMetadata.apply(this, arguments);
|
|
594
616
|
}
|
|
595
617
|
|
|
@@ -626,7 +648,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
626
648
|
}, _callee10, this);
|
|
627
649
|
}));
|
|
628
650
|
|
|
629
|
-
function appendChunksToUpload(_x24, _x25
|
|
651
|
+
function appendChunksToUpload(_x23, _x24, _x25) {
|
|
630
652
|
return _appendChunksToUpload.apply(this, arguments);
|
|
631
653
|
}
|
|
632
654
|
|
|
@@ -699,10 +721,11 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
699
721
|
|
|
700
722
|
case 8:
|
|
701
723
|
response = _context11.sent;
|
|
702
|
-
|
|
724
|
+
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
725
|
+
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
703
726
|
return _context11.abrupt("return", response);
|
|
704
727
|
|
|
705
|
-
case
|
|
728
|
+
case 12:
|
|
706
729
|
case "end":
|
|
707
730
|
return _context11.stop();
|
|
708
731
|
}
|
|
@@ -710,7 +733,7 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
710
733
|
}, _callee11, this);
|
|
711
734
|
}));
|
|
712
735
|
|
|
713
|
-
function request(
|
|
736
|
+
function request(_x26) {
|
|
714
737
|
return _request2.apply(this, arguments);
|
|
715
738
|
}
|
|
716
739
|
|
|
@@ -722,14 +745,30 @@ var MediaStore = /*#__PURE__*/function () {
|
|
|
722
745
|
|
|
723
746
|
exports.MediaStore = MediaStore;
|
|
724
747
|
|
|
725
|
-
function
|
|
726
|
-
|
|
748
|
+
var getValueFromSessionStorage = function getValueFromSessionStorage(key) {
|
|
749
|
+
return window && window.sessionStorage && window.sessionStorage.getItem(key) || undefined;
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
var setKeyValueInSessionStorage = function setKeyValueInSessionStorage(key, value) {
|
|
753
|
+
if (!value || !(window && window.sessionStorage)) {
|
|
727
754
|
return;
|
|
728
755
|
}
|
|
729
756
|
|
|
730
|
-
var
|
|
757
|
+
var currentValue = window.sessionStorage.getItem(key);
|
|
731
758
|
|
|
732
|
-
if (
|
|
733
|
-
window.sessionStorage.setItem(
|
|
759
|
+
if (currentValue !== value) {
|
|
760
|
+
window.sessionStorage.setItem(key, value);
|
|
734
761
|
}
|
|
735
|
-
}
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
var getMediaEnvironment = function getMediaEnvironment() {
|
|
765
|
+
return getValueFromSessionStorage(MEDIA_API_ENVIRONMENT);
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
exports.getMediaEnvironment = getMediaEnvironment;
|
|
769
|
+
|
|
770
|
+
var getMediaRegion = function getMediaRegion() {
|
|
771
|
+
return getValueFromSessionStorage(MEDIA_API_REGION);
|
|
772
|
+
};
|
|
773
|
+
|
|
774
|
+
exports.getMediaRegion = getMediaRegion;
|
package/dist/cjs/constants.js
CHANGED
|
@@ -3,11 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.RECENTS_COLLECTION = exports.MAX_RESOLUTION = exports.FILE_CACHE_MAX_AGE = void 0;
|
|
6
|
+
exports.RECENTS_COLLECTION = exports.PROCESSING_BATCH_SIZE = exports.MAX_UPLOAD_FILE_SIZE = exports.MAX_RESOLUTION = exports.FILE_CACHE_MAX_AGE = exports.CHUNK_SIZE = void 0;
|
|
7
|
+
|
|
8
|
+
var _media = require("./models/media");
|
|
9
|
+
|
|
7
10
|
var RECENTS_COLLECTION = 'recents';
|
|
8
11
|
exports.RECENTS_COLLECTION = RECENTS_COLLECTION;
|
|
9
12
|
var FILE_CACHE_MAX_AGE = 60 * 60 * 24 * 30; // Retain for 30 days
|
|
10
13
|
|
|
11
14
|
exports.FILE_CACHE_MAX_AGE = FILE_CACHE_MAX_AGE;
|
|
12
15
|
var MAX_RESOLUTION = 4096;
|
|
13
|
-
exports.MAX_RESOLUTION = MAX_RESOLUTION;
|
|
16
|
+
exports.MAX_RESOLUTION = MAX_RESOLUTION;
|
|
17
|
+
var CHUNK_SIZE = 4 * _media.DATA_UNIT.MB;
|
|
18
|
+
exports.CHUNK_SIZE = CHUNK_SIZE;
|
|
19
|
+
var PROCESSING_BATCH_SIZE = 1000;
|
|
20
|
+
exports.PROCESSING_BATCH_SIZE = PROCESSING_BATCH_SIZE;
|
|
21
|
+
var MAX_UPLOAD_FILE_SIZE = 2 * _media.DATA_UNIT.TB;
|
|
22
|
+
exports.MAX_UPLOAD_FILE_SIZE = MAX_UPLOAD_FILE_SIZE;
|
package/dist/cjs/index.js
CHANGED
|
@@ -135,12 +135,6 @@ Object.defineProperty(exports, "getDimensionsFromBlob", {
|
|
|
135
135
|
return _getDimensionsFromBlob.getDimensionsFromBlob;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
|
-
Object.defineProperty(exports, "getFileStreamsCache", {
|
|
139
|
-
enumerable: true,
|
|
140
|
-
get: function get() {
|
|
141
|
-
return _fileStreamsCache.getFileStreamsCache;
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
138
|
Object.defineProperty(exports, "getMediaClient", {
|
|
145
139
|
enumerable: true,
|
|
146
140
|
get: function get() {
|
|
@@ -153,6 +147,18 @@ Object.defineProperty(exports, "getMediaClientErrorReason", {
|
|
|
153
147
|
return _errors.getMediaClientErrorReason;
|
|
154
148
|
}
|
|
155
149
|
});
|
|
150
|
+
Object.defineProperty(exports, "getMediaEnvironment", {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function get() {
|
|
153
|
+
return _mediaStore.getMediaEnvironment;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, "getMediaRegion", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function get() {
|
|
159
|
+
return _mediaStore.getMediaRegion;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
156
162
|
exports.getMediaTypeFromMimeType = void 0;
|
|
157
163
|
Object.defineProperty(exports, "globalMediaEventEmitter", {
|
|
158
164
|
enumerable: true,
|
package/dist/cjs/models/media.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isPreviewableType = exports.isMediaCollectionItemFullDetails = void 0;
|
|
6
|
+
exports.isPreviewableType = exports.isMediaCollectionItemFullDetails = exports.DATA_UNIT = void 0;
|
|
7
7
|
|
|
8
8
|
var _mediaCommon = require("@atlaskit/media-common");
|
|
9
9
|
|
|
@@ -24,4 +24,12 @@ var isMediaCollectionItemFullDetails = function isMediaCollectionItemFullDetails
|
|
|
24
24
|
return !!mediaCollectionItem['mediaType'] && !!mediaCollectionItem['mimeType'] && !!mediaCollectionItem['processingStatus'];
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
exports.isMediaCollectionItemFullDetails = isMediaCollectionItemFullDetails;
|
|
27
|
+
exports.isMediaCollectionItemFullDetails = isMediaCollectionItemFullDetails;
|
|
28
|
+
var DATA_UNIT;
|
|
29
|
+
exports.DATA_UNIT = DATA_UNIT;
|
|
30
|
+
|
|
31
|
+
(function (DATA_UNIT) {
|
|
32
|
+
DATA_UNIT[DATA_UNIT["MB"] = 1048576] = "MB";
|
|
33
|
+
DATA_UNIT[DATA_UNIT["GB"] = 1073741824] = "GB";
|
|
34
|
+
DATA_UNIT[DATA_UNIT["TB"] = 1099511627776] = "TB";
|
|
35
|
+
})(DATA_UNIT || (exports.DATA_UNIT = DATA_UNIT = {}));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fileSizeError = exports.calculateChunkSize = void 0;
|
|
7
|
+
|
|
8
|
+
var _media = require("../models/media");
|
|
9
|
+
|
|
10
|
+
var _constants = require("../constants");
|
|
11
|
+
|
|
12
|
+
var fileSizeError = 'fileSizeExceedsLimit';
|
|
13
|
+
/**
|
|
14
|
+
* This is a helper to dynamically calculate the chunk size for a given file size.
|
|
15
|
+
*
|
|
16
|
+
* @param fileSize The size of a file to calculate the chunk size for.
|
|
17
|
+
* @returns A number of bytes per chunk or Throws an Error if the file size exceeds 2TB
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://product-fabric.atlassian.net/wiki/spaces/FIL/pages/3221881143/Rule+of+thumb+for+chunk+sizes#Given-the-following-conditions}
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
exports.fileSizeError = fileSizeError;
|
|
24
|
+
|
|
25
|
+
var calculateChunkSize = function calculateChunkSize(fileSize) {
|
|
26
|
+
if (fileSize > _constants.MAX_UPLOAD_FILE_SIZE) {
|
|
27
|
+
throw new Error(fileSizeError);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (fileSize <= 5 * _media.DATA_UNIT.GB) {
|
|
31
|
+
return 5 * _media.DATA_UNIT.MB;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (fileSize > 5 * _media.DATA_UNIT.GB && fileSize <= 50 * _media.DATA_UNIT.GB) {
|
|
35
|
+
return 50 * _media.DATA_UNIT.MB;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (fileSize > 50 * _media.DATA_UNIT.GB && fileSize <= 0.95 * _media.DATA_UNIT.TB) {
|
|
39
|
+
return 100 * _media.DATA_UNIT.MB;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return 210 * _media.DATA_UNIT.MB;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.calculateChunkSize = calculateChunkSize;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.UploaderError = void 0;
|
|
9
|
+
exports.isUploaderError = isUploaderError;
|
|
10
|
+
|
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
+
|
|
13
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
|
+
|
|
15
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
|
+
|
|
17
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
18
|
+
|
|
19
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
20
|
+
|
|
21
|
+
var _errors = require("../models/errors");
|
|
22
|
+
|
|
23
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
24
|
+
|
|
25
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
26
|
+
|
|
27
|
+
var UploaderError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
28
|
+
(0, _inherits2.default)(UploaderError, _BaseMediaClientError);
|
|
29
|
+
|
|
30
|
+
var _super = _createSuper(UploaderError);
|
|
31
|
+
|
|
32
|
+
function UploaderError(reason, id, metadata) {
|
|
33
|
+
var _this;
|
|
34
|
+
|
|
35
|
+
(0, _classCallCheck2.default)(this, UploaderError);
|
|
36
|
+
_this = _super.call(this, reason);
|
|
37
|
+
_this.reason = reason;
|
|
38
|
+
_this.id = id;
|
|
39
|
+
_this.metadata = metadata;
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
(0, _createClass2.default)(UploaderError, [{
|
|
44
|
+
key: "attributes",
|
|
45
|
+
get: function get() {
|
|
46
|
+
var reason = this.reason,
|
|
47
|
+
id = this.id,
|
|
48
|
+
_this$metadata = this.metadata;
|
|
49
|
+
_this$metadata = _this$metadata === void 0 ? {} : _this$metadata;
|
|
50
|
+
var collectionName = _this$metadata.collectionName,
|
|
51
|
+
occurrenceKey = _this$metadata.occurrenceKey;
|
|
52
|
+
return {
|
|
53
|
+
reason: reason,
|
|
54
|
+
id: id,
|
|
55
|
+
collectionName: collectionName,
|
|
56
|
+
occurrenceKey: occurrenceKey
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}]);
|
|
60
|
+
return UploaderError;
|
|
61
|
+
}(_errors.BaseMediaClientError);
|
|
62
|
+
|
|
63
|
+
exports.UploaderError = UploaderError;
|
|
64
|
+
|
|
65
|
+
function isUploaderError(err) {
|
|
66
|
+
return err instanceof UploaderError;
|
|
67
|
+
}
|
|
@@ -17,7 +17,15 @@ var _from = require("rxjs/observable/from");
|
|
|
17
17
|
|
|
18
18
|
var _concatMap = require("rxjs/operators/concatMap");
|
|
19
19
|
|
|
20
|
-
var _hasherCreator = require("
|
|
20
|
+
var _hasherCreator = require("../utils/hashing/hasherCreator");
|
|
21
|
+
|
|
22
|
+
var _error = require("./error");
|
|
23
|
+
|
|
24
|
+
var _constants = require("../constants");
|
|
25
|
+
|
|
26
|
+
var _calculateChunkSize = require("./calculateChunkSize");
|
|
27
|
+
|
|
28
|
+
var _mediaCommon = require("@atlaskit/media-common");
|
|
21
29
|
|
|
22
30
|
var hashingFunction = /*#__PURE__*/function () {
|
|
23
31
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(blob) {
|
|
@@ -46,7 +54,7 @@ var hashingFunction = /*#__PURE__*/function () {
|
|
|
46
54
|
};
|
|
47
55
|
}();
|
|
48
56
|
|
|
49
|
-
var createProbingFunction = function createProbingFunction(store,
|
|
57
|
+
var createProbingFunction = function createProbingFunction(store, collectionName) {
|
|
50
58
|
return /*#__PURE__*/function () {
|
|
51
59
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(chunks) {
|
|
52
60
|
var response, results;
|
|
@@ -55,7 +63,9 @@ var createProbingFunction = function createProbingFunction(store, collection) {
|
|
|
55
63
|
switch (_context2.prev = _context2.next) {
|
|
56
64
|
case 0:
|
|
57
65
|
_context2.next = 2;
|
|
58
|
-
return store.probeChunks(hashedChunks(chunks),
|
|
66
|
+
return store.probeChunks(hashedChunks(chunks), {
|
|
67
|
+
collectionName: collectionName
|
|
68
|
+
});
|
|
59
69
|
|
|
60
70
|
case 2:
|
|
61
71
|
response = _context2.sent;
|
|
@@ -78,9 +88,11 @@ var createProbingFunction = function createProbingFunction(store, collection) {
|
|
|
78
88
|
}();
|
|
79
89
|
};
|
|
80
90
|
|
|
81
|
-
var createUploadingFunction = function createUploadingFunction(store,
|
|
91
|
+
var createUploadingFunction = function createUploadingFunction(store, collectionName) {
|
|
82
92
|
return function (chunk) {
|
|
83
|
-
return store.uploadChunk(chunk.hash, chunk.blob,
|
|
93
|
+
return store.uploadChunk(chunk.hash, chunk.blob, {
|
|
94
|
+
collectionName: collectionName
|
|
95
|
+
});
|
|
84
96
|
};
|
|
85
97
|
};
|
|
86
98
|
|
|
@@ -158,16 +170,39 @@ var createFileFromUpload = /*#__PURE__*/function () {
|
|
|
158
170
|
var uploadFile = function uploadFile(file, store, uploadableFileUpfrontIds, callbacks) {
|
|
159
171
|
var content = file.content,
|
|
160
172
|
collection = file.collection;
|
|
161
|
-
var deferredUploadId = uploadableFileUpfrontIds.deferredUploadId
|
|
173
|
+
var deferredUploadId = uploadableFileUpfrontIds.deferredUploadId,
|
|
174
|
+
id = uploadableFileUpfrontIds.id,
|
|
175
|
+
occurrenceKey = uploadableFileUpfrontIds.occurrenceKey;
|
|
176
|
+
var chunkSize = _constants.CHUNK_SIZE;
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
if (content instanceof Blob && (0, _mediaCommon.getMediaFeatureFlag)('mediaUploadApiV2', store.featureFlags)) {
|
|
180
|
+
chunkSize = (0, _calculateChunkSize.calculateChunkSize)(content.size);
|
|
181
|
+
}
|
|
182
|
+
} catch (err) {
|
|
183
|
+
if (err instanceof Error && err.message === _calculateChunkSize.fileSizeError) {
|
|
184
|
+
callbacks === null || callbacks === void 0 ? void 0 : callbacks.onUploadFinish(new _error.UploaderError(err.message, id, {
|
|
185
|
+
collectionName: collection,
|
|
186
|
+
occurrenceKey: occurrenceKey
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
cancel: function cancel() {
|
|
192
|
+
callbacks === null || callbacks === void 0 ? void 0 : callbacks.onUploadFinish('canceled');
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
162
197
|
var chunkinatorObservable = (0, _chunkinator.chunkinator)(content, {
|
|
163
198
|
hashingFunction: hashingFunction,
|
|
164
199
|
hashingConcurrency: 5,
|
|
165
200
|
probingBatchSize: 100,
|
|
166
|
-
chunkSize:
|
|
201
|
+
chunkSize: chunkSize,
|
|
167
202
|
uploadingConcurrency: 3,
|
|
168
203
|
uploadingFunction: createUploadingFunction(store, collection),
|
|
169
204
|
probingFunction: createProbingFunction(store, collection),
|
|
170
|
-
processingBatchSize:
|
|
205
|
+
processingBatchSize: _constants.PROCESSING_BATCH_SIZE,
|
|
171
206
|
processingFunction: createProcessingFunction(store, deferredUploadId, collection)
|
|
172
207
|
}, {
|
|
173
208
|
onProgress: function onProgress(progress) {
|
|
@@ -48,6 +48,8 @@ var RequestError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
|
48
48
|
_this$metadata = _this$metadata === void 0 ? {} : _this$metadata;
|
|
49
49
|
var method = _this$metadata.method,
|
|
50
50
|
endpoint = _this$metadata.endpoint,
|
|
51
|
+
mediaRegion = _this$metadata.mediaRegion,
|
|
52
|
+
mediaEnv = _this$metadata.mediaEnv,
|
|
51
53
|
attempts = _this$metadata.attempts,
|
|
52
54
|
clientExhaustedRetries = _this$metadata.clientExhaustedRetries,
|
|
53
55
|
statusCode = _this$metadata.statusCode,
|
|
@@ -56,6 +58,8 @@ var RequestError = /*#__PURE__*/function (_BaseMediaClientError) {
|
|
|
56
58
|
reason: reason,
|
|
57
59
|
method: method,
|
|
58
60
|
endpoint: endpoint,
|
|
61
|
+
mediaRegion: mediaRegion,
|
|
62
|
+
mediaEnv: mediaEnv,
|
|
59
63
|
attempts: attempts,
|
|
60
64
|
clientExhaustedRetries: clientExhaustedRetries,
|
|
61
65
|
statusCode: statusCode,
|