mirror of
https://github.com/directus/directus.git
synced 2026-02-08 00:35:10 -05:00
Add Unsupported Media Type Exception (#11096)
* add unsuported media type exception * throw error when not multipart/form-data * use unsupportedMediaType when checking import file * add `UNSUPPORTED_MEDIA_TYPE` to Error Codes docs
This commit is contained in:
@@ -2,7 +2,12 @@ import argon2 from 'argon2';
|
||||
import { Router } from 'express';
|
||||
import Joi from 'joi';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { ForbiddenException, InvalidPayloadException, InvalidQueryException } from '../exceptions';
|
||||
import {
|
||||
ForbiddenException,
|
||||
InvalidPayloadException,
|
||||
InvalidQueryException,
|
||||
UnsupportedMediaTypeException,
|
||||
} from '../exceptions';
|
||||
import collectionExists from '../middleware/collection-exists';
|
||||
import { respond } from '../middleware/respond';
|
||||
import { RevisionsService, UtilsService, ImportService } from '../services';
|
||||
@@ -94,6 +99,9 @@ router.post(
|
||||
'/import/:collection',
|
||||
collectionExists,
|
||||
asyncHandler(async (req, res, next) => {
|
||||
if (req.is('multipart/form-data') === false)
|
||||
throw new UnsupportedMediaTypeException(`Unsupported Content-Type header`);
|
||||
|
||||
const service = new ImportService({
|
||||
accountability: req.accountability,
|
||||
schema: req.schema,
|
||||
|
||||
Reference in New Issue
Block a user