Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
form.parse(req, function (error, fields, files) {
if(error) {
if (form.bytesExpected > form.maxFileSize) {
return cb2(new Error(app.polyglot.t('app.uploadsizeerror', {
max: bytes.format(form.maxFileSize),
size: bytes.format(form.bytesExpected)
})));
}
return cb2(error);
}
var formAssetDirs = (fields.formAssetFolders && fields.formAssetFolders.length) ? fields.formAssetFolders.split(',') : [];
formTags = (fields.tags && fields.tags.length) ? fields.tags.split(',') : [];
cleanFormAssetDirs = formAssetDirs.map(item => item.trim());
// upzip the uploaded file
helpers.unzip(files.file.path, COURSE_ROOT_FOLDER, function(error) {
if(error) return cb2(error);
cleanupDirs.push(files.file.path, COURSE_ROOT_FOLDER);
cb2();
});
});
}
form.parse(req, function (error, fields, files) {
if(error) {
if (form.bytesExpected > form.maxFileSize) {
return cb2(new Error(app.polyglot.t('app.uploadsizeerror', {
max: bytes.format(form.maxFileSize),
size: bytes.format(form.bytesExpected)
})));
}
return cb2(error);
}
var formAssetDirs = (fields.formAssetFolders && fields.formAssetFolders.length) ? fields.formAssetFolders.split(',') : [];
importInfo['formTags'] = (fields.tags && fields.tags.length) ? fields.tags.split(',') : [];
cleanFormAssetDirs = formAssetDirs.map(item => item.trim());
// clear any previous import files
fs.emptyDir(COURSE_ROOT_FOLDER, function(error) {
if(error) return cb2(error);
// upzip the uploaded file
logger.log('info', 'unzipping');
logger.log('info', COURSE_ROOT_FOLDER);
logger.log('info', files.file.path)
},
{
name: imageSizeName,
title:
"Image size and file type proportion(Text, Image, Document, Compression, Others)",
value: bytes.format(basicInfo.sizeBytes)
},
{
name: userSizeName,
title: "All bytes except for the base image",
value: bytes.format(basicInfo.userSizeBytes)
},
{
name: wastedSizeName,
title: "All bytes of remove or duplicate files",
value: bytes.format(basicInfo.wastedBytes)
}
];
const renderEfficiencyScoreProgress = item => {
if (item.name !== efficiencyScoreName) {
return;
}
return (
const formatSize = d => chalk.bold(bytes.format(d, bytesConfig));
)}`
}
const { size, prettySize } = result
const sizeLimit = options.limit && bytes.parse(options.limit)
const exceededSizeLimit = size > sizeLimit
if (exceededSizeLimit) {
process.exitCode = 1
}
return exceededSizeLimit
? `${padRight(names[index], maxLength)} ${colors.red(
prettySize
)} ${colors.red(
`(limit: ${bytes.format(sizeLimit, {
unitSeparator: ' '
})})`
)}`
: `${padRight(names[index], maxLength)} ${colors.green(prettySize)}`
}
function formatBytes (size) {
return bytes.format(size, { unitSeparator: ' ' })
}
const validateMaxpayload = function({ maxpayload, minMaxpayload }) {
const maxpayloadA = parseBytes(maxpayload)
if (maxpayloadA === null || Number.isNaN(maxpayloadA)) {
const message =
'\'config.limits.maxpayload\' must be a size in bytes, which can include "B", "KB", "MB", "GB" or "TB"'
throwError(message, { reason: 'CONFIG_VALIDATION' })
}
if (maxpayloadA < minMaxpayload) {
const minMaxpayloadA = formatBytes(minMaxpayload)
const message = `'config.limits.maxpayload' must be at least ${minMaxpayloadA}`
throwError(message, { reason: 'CONFIG_VALIDATION' })
}
}