0

I am trying to implement the creation of product on my MEAN app. I have created a Mongoose schema and connection to the database is working, all fields on frontend also work and the product gets inserted into the database.

Now I want to add an image to the product but can't find an answer here for something like that. I know there are a lot of questions like this one (example: Angular2 ExpressJs - File upload to the server), but the answers are for image upload only and I don't know how to implement it on my project. Can someone help?

There are too many lines of code to put here and I think it would be hard to read, so here is a link to GitHub: https://github.com/Janchey/groovy.git

5
  • are you looking for something like multer? Commented Mar 29, 2018 at 18:53
  • "but the answers are for image upload only" I may be misunderstanding your question. Isn't an image upload what you are looking for? Commented Mar 29, 2018 at 19:00
  • @SibaprasadMaiti Yea something like multer. Commented Mar 29, 2018 at 19:06
  • @Pace The problem is that I don't know how to implement it in my project. Schemas are only for image and in mine are a title, artist, writer, image etc. Not sure if I need function only for image upload, or can some code be added in already created function for product saving...? Commented Mar 29, 2018 at 19:12
  • Both methods will work. I would only bother with a multipart request if you needed things to be transnational or atomic in some way. A lot of sites these days seem to first have you upload your images and then post your request after they have uploaded. You might get a preview or be able to add comments or tag people in between. Commented Mar 30, 2018 at 22:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.