multer icon indicating copy to clipboard operation
multer copied to clipboard

Uploaded multipart is undefined

Open badgooooor opened this issue 3 years ago • 2 comments

I have tried using multer for uploading file and used Postman for testing endpoint. I have checked both header and name of file's attribute in form-data (which is the same both in the source code and Postman request).

import * as express from "express";
import * as multer from "multer";

const uploader = multer({
    storage: multer.memoryStorage(),
    limits: {
        fileSize: 5 * 1024 * 1024, // keep images size < 5 MB
    },
});

const router: express.IRouter = express.Router();

router.post("/upload", 
    uploader.single('file'),
    async function (request: express.Request, response: express.Response) {
      console.log("file",request.file);
      console.log("files", request.files);
    });

badgooooor avatar Jan 20 '21 15:01 badgooooor

Hey; I have same error ? Did you solve it ?

mahiraltinkaya avatar Feb 12 '21 12:02 mahiraltinkaya

Hey,

have you tried with import multer from "multer"; instead of import * as multer from "multer"; ?

billybetz avatar Aug 23 '21 20:08 billybetz