diff --git a/lib/browser/managed-upload.js b/lib/browser/managed-upload.js index 147509238..002a40447 100644 --- a/lib/browser/managed-upload.js +++ b/lib/browser/managed-upload.js @@ -301,16 +301,16 @@ proto._createStream = function _createStream(file, start, end) { proto._getPartSize = function _getPartSize(fileSize, partSize) { const maxNumParts = 10 * 1000; - const defaultPartSize = 1024 * 1024; + const defaultPartSize = 1 * 1024 * 1024; - if (!partSize) { - return defaultPartSize; - } + if (!partSize) partSize = defaultPartSize; + const safeSize = Math.ceil(fileSize / maxNumParts); - return Math.max( - Math.ceil(fileSize / maxNumParts), - partSize - ); + if (partSize < safeSize) { + partSize = safeSize; + console.warn(`partSize has been set to ${partSize}, because the partSize you provided causes partNumber to be greater than 10,000`); + } + return partSize; }; proto._divideParts = function _divideParts(fileSize, partSize) { diff --git a/lib/managed-upload.js b/lib/managed-upload.js index 6feac50ec..2a4dd133a 100644 --- a/lib/managed-upload.js +++ b/lib/managed-upload.js @@ -295,14 +295,14 @@ proto._getPartSize = function _getPartSize(fileSize, partSize) { const maxNumParts = 10 * 1000; const defaultPartSize = 1 * 1024 * 1024; - if (!partSize) { - return defaultPartSize; - } + if (!partSize) partSize = defaultPartSize; + const safeSize = Math.ceil(fileSize / maxNumParts); - return Math.max( - Math.ceil(fileSize / maxNumParts), - partSize - ); + if (partSize < safeSize) { + partSize = safeSize; + console.warn(`partSize has been set to ${partSize}, because the partSize you provided causes partNumber to be greater than 10,000`); + } + return partSize; }; proto._divideParts = function _divideParts(fileSize, partSize) {