Skip to content

coding-to-music/node-js-upload-image-mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Upload multiple images to MongoDB example

https://node-js-upload-image-mongodb.vercel.app/

https://github.com/coding-to-music/node-js-upload-image-mongodb

https://www.bezkoder.com/node-js-upload-store-images-mongodb/

https://github.com/bezkoder/node-js-upload-image-mongodb

For more detail, please visit:

How to upload/store images in MongoDB using Node.js & Express

https://github.com/bezkoder/node-js-upload-image-mongodb

Front-end Apps to work with this Node.js Server:

More Practice:

Node.js Express File Upload Rest API example (static folder)

Node.js Express File Upload with Google Cloud Storage example

Upload & resize multiple images in Node.js using Express, Multer, Sharp

Node.js, Express & MongoDb: Build a CRUD Rest Api example

Server side Pagination in Node.js with MongoDB and Mongoose

Node.js + MongoDB: User Authentication & Authorization with JWT

Associations:

MongoDB One-to-One relationship tutorial with Mongoose examples

MongoDB One-to-Many Relationship tutorial with Mongoose examples

MongoDB Many-to-Many Relationship with Mongoose examples

Integration (run back-end & front-end on same server/port)

Integrate React with Node.js Restful Services

Integrate Angular with Node.js Restful Services

Integrate Vue with Node.js Restful Services

Project setup

npm install

There are 4 routes:

GET: Home page for the upload form.
– POST "/upload" to call the uploadFiles function of the controller. This is also for action="/upload" in the view.
– GET /files for list of Images.
– GET /files/:name to download the image with the file name.

Start the mongod database server

mongod

Run

node src/server.js

Go to route files

http://localhost:8080/files

Output

{"message":"No files found!"}


Upload a file

```java
http://localhost:8080/

Output

{"message":"Files have been uploaded."}

Upload a file

http://localhost:8080/files

Output

[{"name":"1640923740720-bezkoder-step5d.png","url":"http://localhost:8080/files/1640923740720-bezkoder-step5d.png"}]

Console Output

Running at localhost:8080
[
  {
    fieldname: 'file',
    originalname: 'step5d.png',
    encoding: '7bit',
    mimetype: 'image/png',
    id: new ObjectId("61ce825c48a0585965e88d45"),
    filename: '1640923740720-bezkoder-step5d.png',
    metadata: null,
    bucketName: 'photos',
    chunkSize: 261120,
    size: 118473,
    md5: undefined,
    uploadDate: 2021-12-31T04:09:00.799Z,
    contentType: 'image/png'
  }
]

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •