1 | ;
|
2 | /**
|
3 | * -------------------------------------------------------------------------------------------
|
4 | * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
|
5 | * See License in the project root for license information.
|
6 | * -------------------------------------------------------------------------------------------
|
7 | */
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | exports.getValidRangeSize = void 0;
|
10 | /**
|
11 | * @module OneDriveLargeFileUploadTaskUtil
|
12 | */
|
13 | /**
|
14 | * @constant
|
15 | * Default value for the rangeSize
|
16 | * Recommended size is between 5 - 10 MB {@link https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession#best-practices}
|
17 | */
|
18 | var DEFAULT_FILE_SIZE = 5 * 1024 * 1024;
|
19 | /**
|
20 | * @constant
|
21 | * Rounds off the given value to a multiple of 320 KB
|
22 | * @param {number} value - The value
|
23 | * @returns The rounded off value
|
24 | */
|
25 | var roundTo320KB = function (value) {
|
26 | if (value > 320 * 1024) {
|
27 | value = Math.floor(value / (320 * 1024)) * 320 * 1024;
|
28 | }
|
29 | return value;
|
30 | };
|
31 | /**
|
32 | * @constant
|
33 | * Get the valid rangeSize for a file slicing (validity is based on the constrains mentioned in here
|
34 | * {@link https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession#upload-bytes-to-the-upload-session})
|
35 | *
|
36 | * @param {number} [rangeSize = DEFAULT_FILE_SIZE] - The rangeSize value.
|
37 | * @returns The valid rangeSize
|
38 | */
|
39 | var getValidRangeSize = function (rangeSize) {
|
40 | if (rangeSize === void 0) { rangeSize = DEFAULT_FILE_SIZE; }
|
41 | var sixtyMB = 60 * 1024 * 1024;
|
42 | if (rangeSize > sixtyMB) {
|
43 | rangeSize = sixtyMB;
|
44 | }
|
45 | return roundTo320KB(rangeSize);
|
46 | };
|
47 | exports.getValidRangeSize = getValidRangeSize;
|
48 | //# sourceMappingURL=OneDriveLargeFileUploadTaskUtil.js.map |
\ | No newline at end of file |