How to use the UnsupportedMediaType function from http-errors
Find comprehensive JavaScript http-errors.UnsupportedMediaType code examples handpicked from public code repositorys.
75 76 77 78 79 80 81 82 83 84
uriTooLong: function uriTooLong (message) { return new createError.URITooLong(message) }, unsupportedMediaType: function unsupportedMediaType (message) { return new createError.UnsupportedMediaType(message) }, rangeNotSatisfiable: function rangeNotSatisfiable (message) { return new createError.RangeNotSatisfiable(message)
30
340
17
+ 55 other calls in file
GitHub: mfolkeseth/core
135 136 137 138 139 140 141 142 143 144
pipeline(file, extract, (error) => { if (error) { switch (error.code) { case 'TAR_BAD_ARCHIVE': case 'TAR_ABORT': reject(new HttpError.UnsupportedMediaType()); break; case 'TAR_ENTRY_UNSUPPORTED': case 'TAR_ENTRY_INVALID': case 'TAR_ENTRY_ERROR':
2
1
1
26 27 28 29 30 31 32 33 34 35 36
}); const fileFilter = (req, file, cb) => { if (!file.originalname.match(/\.(jpg|JPG|jpeg|JPEG|png|PNG|gif)$/)) { return cb( createHttpError.UnsupportedMediaType( "Only images are allowed. [jpg|JPG|jpeg|JPEG|png|PNG|gif]" ), false );
2
4
0
22 23 24 25 26 27 28 29 30 31
cb(null, true); } else { cb( null, false, new UnsupportedMediaType( 'Unsupported file format. File should have png, jpeg or jpg formats' ) ); }
1
2
0
+ 2 other calls in file
155 156 157 158 159 160 161 162 163 164
module.exports.Gone = new HTTPErrors.Gone() module.exports.LengthRequired = new HTTPErrors.LengthRequired() module.exports.PreconditionFailed = new HTTPErrors.PreconditionFailed() module.exports.PayloadTooLarge = new HTTPErrors.PayloadTooLarge() module.exports.URITooLong = new HTTPErrors.URITooLong() module.exports.UnsupportedMediaType = new HTTPErrors.UnsupportedMediaType() module.exports.RangeNotSatisfiable = new HTTPErrors.RangeNotSatisfiable() module.exports.ExpectationFailed = new HTTPErrors.ExpectationFailed() module.exports.ImATeapot = new HTTPErrors.ImATeapot() module.exports.MisdirectedRequest = new HTTPErrors.MisdirectedRequest()
1
0
7
+ 41 other calls in file
56 57 58 59 60 61 62 63 64 65
await cloudinary.v2.uploader.upload(file[0].path, { use_filename: false, unique_filename: true, overwrite: true }, (pictureError, pictureResponse) => { if (pictureError) throw new createErrors.UnsupportedMediaType(`Profile picture: ${pictureError.message}`) fs.unlinkSync(file[0].path) data.picture = pictureResponse.secure_url || ''
0
0
0
14 15 16 17 18 19 20 21 22 23
const mimetype = filetypes.test(file.mimetype) if (mimetype && extname) { cb(null, true) } else { cb(new createErrors.UnsupportedMediaType('File type not allowed!'), false) } }, limits: { fileSize: MAX_FILE_SIZE * 1024 * 1024
0
0
0
109 110 111 112 113 114 115 116 117 118
case 414: { httpError = createError.URITooLong(); break; } case 415: { httpError = createError.UnsupportedMediaType(); break; } case 416: { httpError = createError.RangeNotSatisfiable();
0
0
2
+ 41 other calls in file
http-errors.NotFound is the most popular function in http-errors (1819 examples)