(WIP) Drop-in replacement for gridfs-stream, except it stores the files on-disk instead of storing them in the database. Only the metadata is stored in the database and still requires MongoDB.
node index.js
To connect to a different database, change the uri in the Database.js file to the new MongoDB connection link.
- NodeJS "events" package
- NodeJS "mongodb" package
Leave all the gridfs-stream code as is. All what you need to do is 2 things:
- Import Grid from gridfs-stream-local rather than from gridfs-stream
- Call
run()
member function inside the object returned by both createWriteStream and createReadStream. Check the sample code at index.js to understand more.
- GridReadStream reads files given only their id. It does not handle retrieving files by any other parameters.
- GridWriteStream handles empty options parameter and options with filename property only. It does not handle any other options
- The program does not handle writing files with the same name
Gridfs Files:
- Grid.js: is the main class containing instances of GridWriteStream and GridReadStream
- GridReadStream.js: is the class responsible for reading a file's content given its id by firstly retrieving the file's name from the database then reading the file's content.
- GridWriteStream.js: is the class responsible for writing a file given its name by firstly storing the file in the database then writing the file.
Database.js: is responsible for handling everything related to the database. In this file:
- Connection to the database is established.
- Functions for reading and writing are created and exported.
The Apache License, version 2.0. See License
.