If you are getting an error as follows:
Cannot read property 'isLoggedIn' of undefined
And you are using multer in the following fashion:
new Date().toISOString() is the cause of the problem.
Solution:
Either use new Date().getMilliseconds().toString()
Or use uuid for naming the stored file.
Cannot read property 'isLoggedIn' of undefined
And you are using multer in the following fashion:
- const fileStorage = multer.diskStorage({
- destination: (req, file, cb) => {
- cb(null, 'images');
- },
- filename: (req, file, cb) => {
- cb(null, new Date().toISOString() + '-' + file.originalname);
- }
- });
new Date().toISOString() is the cause of the problem.
Solution:
Either use new Date().getMilliseconds().toString()
Or use uuid for naming the stored file.
UUIDV4 Get Started
Installation
$ npm install uuidv4
Quick start
First you need to integrate uuidv4 into your project by using the
require
function:
const uuid = ;
Then you can create UUIDs. To do so simply call the
uuid
function:
console;
Comments
Post a Comment