PS: This project have a JS/Es* Version and Typescript version that i will ry to keep in sync in term of integration, so for sake of clarity the DEV(this branch) will have the JS/ES* Version and ts-build Branch will have the Typescript Version.
As mouthfull as it sounds, but functional it will be, file upload is needed in any application there for this demo shows how we can upload files directly to our MongoDB using it's GridFS System.
This project will be improved in near future to use the new supported version of file management in MongoDB, which is the GridFSBucket, this final support will be ported soon.
In order to use this repository, please feel free to clone directly to your working directory and simply enter this command to your Terminal/CMD :
# yarn install
or, in case your don't dispose yarn, please use the following command:
# npm install
In case you want to run the app, simply use the following command :
# npm start
I've changed the upload endpoints so no in order to upload your documents you will just call for the endpoint bellow :
<localhost|server>/v1/bucket/upload
As an added endpoint, now you can view all your uploaded files using this endpoint:
<localhost|server>/v1/home
This endpoint will give you all uploaded docs within you Database in an array of object that will have the following:
[{
file_name: <uploaded-file-name>,
file_id: <uploaded-file-id>,
file_link: <auto-generated-downnload-link>
}]
- file_name : The uploaded file name.
- file_id : An auto generated _if upon file upload over GridFS.
- file_link : An auto generated download link of your file for easy download.
I've changed the download endpoints so no in order to download your documents you will just call for the endpoint bellow :
<localhost|server>/v1/bucket/download?document_id=<doc-id>
1 - Depedencies upgrade. 2 - Logger updates to match winston v3.3
Finally, for even more details please check this Youtube tutorial I've created that explains just that.
Link : https://youtu.be/pXHOF4GWuZQ
- Houssem Yahiaoui (@houssem-yahiaoui).
Happy Coding =D