@microsoft/microsoft-graph-client
Version:
Microsoft Graph Client Library
48 lines • 1.82 kB
JavaScript
/**
* -------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
* See License in the project root for license information.
* -------------------------------------------------------------------------------------------
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getValidRangeSize = void 0;
/**
* @module OneDriveLargeFileUploadTaskUtil
*/
/**
* @constant
* Default value for the rangeSize
* 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}
*/
var DEFAULT_FILE_SIZE = 5 * 1024 * 1024;
/**
* @constant
* Rounds off the given value to a multiple of 320 KB
* @param {number} value - The value
* @returns The rounded off value
*/
var roundTo320KB = function (value) {
if (value > 320 * 1024) {
value = Math.floor(value / (320 * 1024)) * 320 * 1024;
}
return value;
};
/**
* @constant
* Get the valid rangeSize for a file slicing (validity is based on the constrains mentioned in here
* {@link https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/driveitem_createuploadsession#upload-bytes-to-the-upload-session})
*
* @param {number} [rangeSize = DEFAULT_FILE_SIZE] - The rangeSize value.
* @returns The valid rangeSize
*/
var getValidRangeSize = function (rangeSize) {
if (rangeSize === void 0) { rangeSize = DEFAULT_FILE_SIZE; }
var sixtyMB = 60 * 1024 * 1024;
if (rangeSize > sixtyMB) {
rangeSize = sixtyMB;
}
return roundTo320KB(rangeSize);
};
exports.getValidRangeSize = getValidRangeSize;
//# sourceMappingURL=OneDriveLargeFileUploadTaskUtil.js.map
;