1
Argos
2y

Multer is shit.

Do you know how to validate file size + mime type of the file before saving it to the disk?

Here is an instruction:

1. In one place you provide a it a fileFilter function that will validate the mime type, but this function can not validate file size or send user response.
2. In second place provide it a config limits file, that will validate file size, but can not validate mime type
3. In third place you provide middleware to capture any errors caused by previous 2 places and send response back to the user.
4. Go google for what is cb in multer because their shit documentation says nothing about it

Such simple thing as request->validation->response is split into 3 different parts, each of different type: callback, config file and middleware.

Why do so much people use this shit written by a braindead retarded morons?

Comments
  • 0
    Wouldn't just chain those validations together in separate functions and have next() at the end?

    This probably makes no sense. But hopefully you understand what I'm trying to convey.

    Let me know if you already tried this, curious about your journey.
  • 0
    I don't get why it's separate from the request callback, you should totally be allowed to check what you need to check and then hand the connection over to multer with a (possibly user and operation dependent) size limit.
  • 1
    In HTTP, the size of a file is a fundamentally different kind of property from its mime type. They're available under different conditions, at different times.

    cb is a name you assigned to the third parameter provided to your lambda. It's a callback and it's probably documented under the function you're calling with the lambda.
Add Comment