{"id":27886024,"url":"https://github.com/azita-abdollahi/file-server","last_synced_at":"2026-04-10T12:31:44.639Z","repository":{"id":49388845,"uuid":"517624437","full_name":"azita-abdollahi/file-server","owner":"azita-abdollahi","description":"Upload File to MongoDB using  ExpressJs+ Docker+ Nginx+ Mongo-Express","archived":false,"fork":false,"pushed_at":"2024-09-24T06:20:22.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-27T22:19:52.116Z","etag":null,"topics":["docker","docker-compose","expressjs","gridfs","mongo-express","mongodb","mongoosejs","multer","multer-gridfs-storage","nginx","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/azita-abdollahi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-07-25T10:46:11.000Z","updated_at":"2025-05-26T19:16:35.000Z","dependencies_parsed_at":"2025-05-29T04:28:44.496Z","dependency_job_id":"75d946ce-0730-4aae-8a47-043fed839a89","html_url":"https://github.com/azita-abdollahi/file-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/azita-abdollahi/file-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azita-abdollahi%2Ffile-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azita-abdollahi%2Ffile-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azita-abdollahi%2Ffile-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azita-abdollahi%2Ffile-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azita-abdollahi","download_url":"https://codeload.github.com/azita-abdollahi/file-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azita-abdollahi%2Ffile-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31642708,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T07:40:12.752Z","status":"ssl_error","status_checked_at":"2026-04-10T07:40:11.664Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","expressjs","gridfs","mongo-express","mongodb","mongoosejs","multer","multer-gridfs-storage","nginx","nodejs"],"created_at":"2025-05-05T07:51:22.459Z","updated_at":"2026-04-10T12:31:44.440Z","avatar_url":"https://github.com/azita-abdollahi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Uploading Files to `MongoDB` with `GridFS` and `Multer` Using `NodeJS`, `Nginx` (web server)  and `mongo-express`(Web-based MongoDB admin interface, written with Node.js and express)\n\n\n\n[`GridFS`](https://www.mongodb.com/docs/manual/core/gridfs/) is a specification that describes how to split files into chunks during storage and reassemble them during retrieval. The driver implementation of `GridFS` manages the operations and organization of the file storage.\n\nYou should use `GridFS` if the size of your file exceeds the BSON-document size limit of 16 megabytes.\n\n`GridFS` organizes files in a **bucket**, a group of MongoDB collections that contain the chunks of files and descriptive information. Buckets contain the following collections, named using the convention defined in the `GridFS` specification:\n\n- The `chunks` collection stores the binary file chunks.\n- The `files` collection stores the file metadata.\n\nWhen you create a new `GridFS` bucket, the driver creates the `chunks` and `files` collections, prefixed with the default bucket name `fs`, unless you specify a different name.\n\n​\t![GridFS-upload](https://user-images.githubusercontent.com/108535307/180761360-62972007-f099-44c8-b723-9aa91a2f27ee.png)\n\n​\tImage source: mongodb.com\n\nUsing this packages:\n\n- [`Mongoose`](https://mongoosejs.com/docs/) (This package will translate the node.JS code to MongoDB)\n- [`Config`](https://www.npmjs.com/package/config) (It lets you define a set of default parameters, and extend them for different deployment environments.\n- [`Express`](https://www.npmjs.com/package/express) (You’ll need this package for any HTTP requests you want to run)\n- [`BodyParser`](https://www.npmjs.com/package/body-parser) (This package lets you receive content from HTML forms)\n- [`Multer`](https://www.npmjs.com/package/multer) (This package enables easy file upload into MongoDB\n- [`Gridfs-stream`](https://www.npmjs.com/package/gridfs-stream) (Easily stream files to and from MongoDB [`GridFS`](http://www.mongodb.org/display/DOCS/GridFS).)\n- [`Multer-gridfs-storage`](https://www.npmjs.com/package/multer-gridfs-storage) (You need this package to implement the MongoDB `GridFS` feature with `multer`).\n\n`docker-compose.yml`:\n\n```yaml\nversion: \"3\"\nservices:\n  backend-file-server:\n    image: file-server\n    container_name: file-server\n    build:\n      context: .\n    restart: on-failure\n    depends_on: \n      - mongodb\n    networks:\n      - file-net\n  mongodb:\n    image: mongo:4.2\n    container_name: mongodb\n    restart: on-failure\n    env_file: ./mongo_env\n    volumes: \n      - ./mongo-data:/data/db\n    networks:\n      - file-net\n  mongo-express:\n    image: mongo-express:0.54.0\n    container_name: mongo-express\n    depends_on:\n      - mongodb\n    networks:\n      - file-net\n    env_file: ./mongo-express_env \n  nginx:\n    image: nginx:1.21\n    container_name: proxy_server\n    restart: on-failure\n    depends_on:\n      - backend\n    networks:\n      - file-net\n    ports:\n      - \"8080:8080\"\n      - \"8081:8081\"\n    volumes:\n      - ./conf.d/:/etc/nginx/conf.d/\nnetworks:\n  file-net:\n```\n\n`Dockerfile`:\n\n```dockerfile\nFROM node:14\nWORKDIR /app\nCOPY package*.json ./\nRUN npm install\nCOPY . .\nEXPOSE 3000\nCMD [\"npm\", \"run\", \"start\"]\n```\n\nRun application:\n\n*Note*: This instruction uses 'docker compose' version 2.\n\n```shell\n# Start Services\ndocker compose up -d --build\n# Stop Services\ndocker compose down\n# All Services Logs\ndocker compose logs -f\n# Log a Specific Service\ndocker compose logs -f \u003cService_Name\u003e\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazita-abdollahi%2Ffile-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazita-abdollahi%2Ffile-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazita-abdollahi%2Ffile-server/lists"}