Skip to content

Commit

Permalink
Fix messages of incorrect file size when uploading media.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nes-si committed Oct 11, 2022
1 parent a036723 commit 0c3a810
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export default class ContentMedia extends ContentBase {
if (!error) {
const unit = fileSizeValid.minUnit == BYTES ? 'bytes' : fileSizeValid.minUnit;
size = convertDataUnits(size, BYTES, fileSizeValid.minUnit);
error = `The file size (${size} ${unit}) is smaller than the permissible value: ${fileSizeValid.min} ${unit}!`;
if (size == fileSizeValid.min || size == 0)
error = `The file size is smaller than the permissible value: ${fileSizeValid.min} ${unit}!`;
else
error = `The file size (${size} ${unit}) is smaller than the permissible value: ${fileSizeValid.min} ${unit}!`;
}
return error;
}
Expand All @@ -69,13 +72,19 @@ export default class ContentMedia extends ContentBase {
if (!error) {
const unit = fileSizeValid.maxUnit == BYTES ? 'bytes' : fileSizeValid.maxUnit;
size = convertDataUnits(size, BYTES, fileSizeValid.maxUnit);
error = `The file size (${size} ${unit}) is greater than the permissible value: ${fileSizeValid.max} ${unit}!`;
if (size == fileSizeValid.max)
error = `The file size is greater than the permissible value: ${fileSizeValid.max} ${unit}!`;
else
error = `The file size (${size} ${unit}) is greater than the permissible value: ${fileSizeValid.max} ${unit}!`;
}
} else {
max = convertDataUnits(FILE_SIZE_MAX, BYTES, M_BYTES);
const unit = M_BYTES;
size = convertDataUnits(size, BYTES, M_BYTES);
error = `The file size (${size} ${unit}) is greater than the permissible value: ${max} ${unit}!`;
if (size == max)
error = `The file size is greater than the permissible value: ${max} ${unit}!`;
else
error = `The file size (${size} ${unit}) is greater than the permissible value: ${max} ${unit}!`;
}
return error;
}
Expand Down

0 comments on commit 0c3a810

Please sign in to comment.