Skip to content

Commit

Permalink
fix: _getPartSize (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
weiyie committed Aug 10, 2020
1 parent 009c0b2 commit 70f6329
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions lib/browser/managed-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions lib/managed-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 70f6329

Please sign in to comment.