express - MongoDb Backend Problem(multer-gridfs-storage) - Stack Overflow

admin2025-04-27  3

my mutler-gridfs-storage is not working properly,it shows cannot read properties of undefined in the console f._id

To succesfuly upload an Image to my Database (MongoDb) I see this cannot set properties of undefined Error

my mutler-gridfs-storage is not working properly,it shows cannot read properties of undefined in the console f._id

To succesfuly upload an Image to my Database (MongoDb) I see this cannot set properties of undefined Error

Share Improve this question asked Jan 11 at 15:00 Joshua AbakahJoshua Abakah 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 2

Ensure that the file is being properly passed to the storage. If it's undefined, you might be facing issues in the upload process itself, which could be due to misconfiguration in the Multer or GridFS setup.

Ensure that you are awaiting this correctly:

const file = await getFileFromGridFS(fileId); 
if (file) {
  console.log(file._id);
} else {
  console.error('File not found');
}

转载请注明原文地址:http://www.anycun.com/QandA/1745707233a91102.html