How to use the ghost-ignition.errors.UnsupportedMediaTypeError function in ghost-ignition

To help you get started, we’ve selected a few ghost-ignition examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TryGhost / gscan / app / middlewares / upload-validation.js View on Github external
const contentTypes = ['application/zip', 'application/x-zip-compressed', 'application/octet-stream'];

    req.file = req.file || {};
    req.file.name = req.file.originalname;
    req.file.type = req.file.mimetype;

    if (!checkFileExists(req.file)) {
        return next(new errors.ValidationError({
            message: `"Please select a zip file.`
        }));
    }

    req.file.ext = path.extname(req.file.name).toLowerCase();

    if (!checkFileIsValid(req.file, contentTypes, extensions)) {
        return next(new errors.UnsupportedMediaTypeError({
            message: 'Please select a valid zip file.'
        }));
    }

    next();
};