Friday 24 February 2017

Multer/MongoDB Issue - Image Saved to DB Correctly, Get a 404 in View

I've asked this question over at SO, with no success, so this is an attempt to cast a wider net. Any help with this would be greatly appreciated. If you want to see all of my code, it's listed in this post: http://ift.tt/2lCZ6tG basically, I'm trying to use Multer/Express/MongoDB to upload an image to the DB, and it appears like I'm successfully saving it to the DB, but when I try to use it in my view, I get this weird 404 Error with a very strange path:CANNOT GET: http://localhost:3090/project/%7B%20contentType:%20'image/png',%20%20data:%…b%2047%2044%2000%20ff%2000%20ff%2000%20ff%20a0%20bd%20a7%20...%20%3E%20%7D 404 (Not Found)I know I'm saving the image in the correct directory and the path that the view is referencing is correct (I know this, because I tested it with images I added to that directory manually, and without saving it to the DB).My understanding is that the image is stored in Binary, so it seems like there is some issue in converting that into the image, but obviously my understanding of this process is rudimentary.So, I thought I was incorrectly storing data in the DB, but using RoboMongo, this is what it looks like, which I believe is correct:http://ift.tt/2lCZ4ly ideas here? Seems like a lot of people struggle with Multer, so I'm also open to using an alternative middleware, if there are any better options.Thanks in advance!

Submitted February 24, 2017 at 01:36PM by wploser

No comments:

Post a Comment