├── .gitignore
├── .github
└── dependabot.yml
├── package.json
├── LICENSE
├── README.md
├── views
└── index.ejs
└── app.js
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: npm
4 | directory: "/"
5 | schedule:
6 | interval: monthly
7 | time: "23:30"
8 | open-pull-requests-limit: 10
9 | ignore:
10 | - dependency-name: mongoose
11 | versions:
12 | - 5.11.12
13 | - 5.11.14
14 | - 5.11.18
15 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nodejs-file-upload",
3 | "version": "1.1.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "node app.js",
8 | "dev": "nodemon app.js"
9 | },
10 | "private": true,
11 | "keywords": [],
12 | "author": "shubhambattoo",
13 | "license": "MIT",
14 | "dependencies": {
15 | "ejs": "^3.1.6",
16 | "express": "^4.18.2",
17 | "mongoose": "^5.12.12",
18 | "multer": "^1.4.2",
19 | "multer-gridfs-storage": "^4.2.0"
20 | },
21 | "devDependencies": {
22 | "nodemon": "^2.0.7"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Shubham Battoo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NodeJS GridFS Upload
2 |
3 | ## Using new gridfs bucket
4 |
5 | About GridFS [read more](https://docs.mongodb.com/manual/core/gridfs/)
6 |
7 | To read more about the GridFS bucket [read more](https://mongodb.github.io/node-mongodb-native/3.2/api/GridFSBucket.html)
8 |
9 | ## Methods working
10 |
11 |
Able to upload files
12 |
Able to retrive files
13 |
Able to Delete files and chunks from the db
14 |
15 |
16 | ## Author
17 |
18 | 👤 **Shubham Battoo**
19 |
20 | * Twitter: [@Shubham_batt](https://twitter.com/Shubham_batt)
21 | * Github: [@shubhambattoo](https://github.com/shubhambattoo)
22 |
23 | ## Usage
24 |
25 | Download or Clone the project, ``` cd node-js-file-upload ```
26 |
27 | then install all the required dev and depenedencies by running
28 |
29 | ```
30 | npm install
31 | ```
32 |
33 | Serve the project
34 |
35 | ```
36 | npm start
37 | ```
38 |
39 | Server starts on the port [http://localhost:5001](http://localhost:5001)
40 |
41 | ### You can follow the following tutorial which describes how all the code works on this repo
42 | [https://dev.to/shubhambattoo/uploading-files-to-mongodb-with-gridfs-and-multer-using-nodejs-5aed](https://dev.to/shubhambattoo/uploading-files-to-mongodb-with-gridfs-and-multer-using-nodejs-5aed)
43 |
44 |
45 |
46 | Give a ⭐️ if this project helped you!
47 |
--------------------------------------------------------------------------------
/views/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Mongo File Upload
10 |
11 |
12 |
13 |