Hello Beautiful people... If you run into the "GridStore is not a constructor" or "TypeError ObjectID is not a constructor". Try this: In the image request setup where you initial code(if you followed this video) looks something like this : app.get('/picture/:name', (req, res) => { if (gfs) { gfs.files.findOne({ filename: req.params.name }).then((file) => { if (!file) return res.status(404).json({ err: 'No File Exists' }); if (['image/jpeg', 'image/jpg', 'image/png', 'image/webp'].includes(file.contentType)) { const readStream = gfs.createReadStream(file.filename); readStream.pipe(res); } else { return res.json({ imagen: file }); } }); } }); Since mongoose deprecated the GridStore class and gridfs-stream didnt keep updating to take this change, you need to do something like this: app.get('/picture/:name', (req, res) => { if (gfs) { gfs.files.findOne({ filename: req.params.name }).then((file) => { if (!file) return res.status(404).json({ err: 'No File Exists' }); if (['image/jpeg', 'image/jpg', 'image/png', 'image/webp'].includes(file.contentType)) { //#############LIKE THIIIISSS###### const bucket = new mongoose.mongo.GridFSBucket(db, {bucketName: 'uploads',}); const readStream = bucket.openDownloadStreamByName(file.filename); readStream.pipe(res); //############################# } else { return res.json({ imagen: file }); } }); } }); Have a good day :D
you prolly dont care at all but does any of you know a way to log back into an instagram account..? I stupidly forgot the password. I love any help you can offer me.
@Cason Mohammed Thanks for your reply. I got to the site thru google and Im in the hacking process now. Looks like it's gonna take quite some time so I will reply here later with my results.
Hello awesome teacher! Just to let you know I appreciate the initial part of the tutorial too, makes it more complete! Thank you so much and keep up with the good work!
⚠️⚠️⚠️ GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead. 👋I think you're also facing this problem. ✅👉 So, here is the solution! //add var let gridFSBucket; let gfs; connection.once('open', () => { gfs = Grid(conn.db, mongoose.mongo); // add value to new var gridFSBucket = new mongoose.mongo.GridFSBucket(conn.db, { bucketName: 'user_images' }); gfs = Grid(connection.db, mongoose.mongo); gfs.collection(image_bucket_name); if (file.contentType === 'image/jpeg' || file.contentType === 'image/png') { //now instead of const readstream = gfs.createReadStream(file.filename); //add this line const readStream = gridFSBucket.openDownloadStream(file._id); readSteam.pipe(res); } }); You're done! 🎉😍
Hey i guess I am facing this problem. Does it mean I should remove GridFsStorage part? which is from 'multer-gridfs-storage' module? Is it why gfs.file.find() does not work anymore?
2019: There are so many changes to Gridfs that I can't even find updated commands for you're better off pulling this down and redoing it. Been stuck on gfs.files and whatever is supposed to replace it for 30 hours.
Fantastic project, I just finished it and have learned a lot from it. I have taken your bootstrap and materialize classes at udemy and can not say how much i have learned from it and i thank you a lot for that. Your classes on udemy are the first i look for when i want to learn more. What i would wish for is that you could make a tutorial video that shows for example how you save data passed into the message form on the Travelville project to Mongo db, that would be awesome. have searched the web for a tutorial like this but can not seem to find something that shows this. Thanks again Brad, and i am pleased to see that your follower count rapidly is increasing, then i know that i am searching at the right place for knowledge :-)
Hi Abbas, I found this video very informative but a little bit out of dated. Did you get this project running? could you please share your code with me (maybe a github repo)? I failed to change the code from MLab to Mongo Atlas. Thanks in advanced
@@haoliang7134 im using it in a private repo. but would help you out! and im not using atlas but have the db locally installed. I am using react. the way im using is : 1. i return the binary data from the collection using aggregate. 2.save the response in state. 3. install b64-to-blob package 4. then : var blob = b64(response.imageData, 'image/jpeg') const url = URL.createObjectURL(blob) b64toBlob(b64Data: string, contentType?: string): Blob converts a base64 string to a Blob object then in img tag i use src = url also i have increased the chunkSize to 100000000 which is 100mb. This makes only one entry in chunk collection. Otherwise i'd have to write: response.imageData.forEach(element => { DataString += element }); then b64toBlob(DataString , 'image/jpeg'):
HI Brad , I find your videos very useful , but I have a request. Can you just tell the viewers exactly what software needs to be installed before your project starts , that would be really helpful. ... thanks man
Премного благодарен Вам сударь за очень познавательный мануал. Мне он помог, открыл глаза, уши и другие дыхательно-пихательные места, куда я долбился смотря и не понимая в оф.документацию. Огросный респект тебе братуха! Привет из России!
I am very grateful to you sir for a very informative manual. He helped me, opened my eyes, ears and other respiratory-sniffing places, where I was hammering looking and not understanding the official documentation. Huge respect to you brother! Hello from Russia!
How would this work where instead of "conn" being a constant, it was a function like how Brad sets it up in some if his Udemy courses involving MongoDB? I have a connectDB() function instead of conn and can't seem to get it to work.
@@DevSprout Hey Ian ..thanks for the download rply can u help me in this .. I have a file stored in gfs collection .. i want to take the imge from database and pass the image to the API ? so if i directly get the file from gfs.files.find() and pass it to the APi will it work?
are you a mind reader? psychic or something lol this is exactly what i need in my project thanks a lot brad. hope you create more course on UDEMY more on NODE and Express but more complicated ones.
Great content, man! I subscribed cause I like your style. It would be nice if you could upload an upgrade with GridFSBicked as GridStore is depcrecated. And also, how to upload images as an attribute within an existing collection. Best!
Hi Brad, If I want to use GridFS-stream with mongoose.connect() instead createConnection() what’s the exact way to do it? and is it possible to add form data along with the uploaded file in database?
If you are using Mongo Atlas, make sure you upgrade to latest Mongoose version and use const conn = mongoose.createConnection( mongoURI , { useNewUrlParser : true, useUnifiedTopology : true } ); ... Otherwise the read file feature may not work.
I have used gfs = Grid(conn.db,mongoose.mongo) in connection.js file and I want to use gfs in router.js file. It is giving error while exporting. Please tell me how to export it and use it in router.js
not able to use createReadSteame as giving error of "Cannot read property 'readPreference' of null", I think mongoose version greater than 5.0.0 not support gridfs
Is there a way to use this in a react app? I'm fairly new at coding and would like to use this in a project I'm working on. Great video, by the way; very informative and easy to follow. Thanks so much for the great tutorials.
I am also using react. the way im using is : 1. i return the binary data from the collection using aggregate. 2.save the response in state. 3. install *b64-to-blob* package 4. then >> var blob = b64(response.imageData, 'image/jpeg') const url = URL.createObjectURL(blob) b64toBlob(b64Data: string, contentType?: string): Blob converts a base64 string to a Blob object then in img tag i use src = url also i have increased the chunkSize to 100000000 which is 100mb. This makes only one entry in chunk collection. Otherwise i'd have to write: response.imageData.forEach(element => { DataString += element }); then b64toBlob(DataString , 'image/jpeg'):
In my case the syntax need to be like this. There are so many changes needed to be done. maybe it is there are some code updates in this packages. gridfs .collection('uploads') .find() .toArray((_err, files) => { if (!files || files.length === 0) { return res.status(404).json({ error: 'file not found' }) } return res.json(files) })
Hi The tutorial is great, good job I think many of your subscribers like your video and sometimes watching videos is not good for someone maybe By reading books, programmers can code freely So what kind of books would you recommend (node js and MongoDb)?
(node:2076) DeprecationWarning: GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead (Use `node --trace-deprecation ...` to show where the warning was created)
What I was missing when that happened was `gfs.collection('uploads');` which is at this point in the video ruclips.net/video/3f5Q9wDePzY/видео.html. His code is also in the description too if you or anyone else gets stuck.
Hello, I found your video very useful, thanks a lot. But I wanna push my files into another collection, there is no model for these files, how to do that??
I'm about to try... My approach is save the imageID to a variable and push or save it into an array or just as a single value. Then in the middleware where I have the model that holds that imageID, search the /files (uploads.files). Sounds good in my head... I'll check back with code once I figure it out!
github.com/programmer-blog/nodejs-file-upload-with-mongodb here's something I found.. they made a Photo model and pretty much did what I was thinking about earlier. From here (after the code in link), looks like we can just reference the Photo _id from the User model. You could build a PhotoBook model that has a photos array that reference Photo _id's as well, then in your User model, reference the PhotoBook _id... hope this helps!
Hi, this is exactly what I am looking for GridFS. Thanks for this wonderful tutorial. I have a doubt, in my case I am creating image in server side itself from basic canvas library so, how can I save this image through GridFS
Thanks Brad for awesome tutorial but i just needed to know how to display files of all type in the show template???? I m working on a project that has this feature!
When writing const conn make sure to write it like "const conn = mongoose.createConnection(mongoURI, {useNewUrlParser: true, useUnifiedTopology: true })". I was getting errors with the files path when I didn't have this.
been trying the modularize your code and its the hardest shit, so when i do modularize it and I export gfs, gfs becomes undefined so after awhile i gave up and just ended up setting my functions for my routes in the same file as the gfs init, then what I found out is that when I use get to do a gfs.files.findOne it says cannot find the filename of null, so apparently it only works post requests with uploads.single() as a middleware... is that really the case?? Ok now it works, so it works sometimes and doesn't sometimes? this is crazy... Wait how do we even get access to gfs? ik that calling .once on mongoose.createConnection is asyncronous therefore gfs would only work if they were all in a single page like what you originally have, but what about when people seperate theyre code to keep it clean, then not all the files would have access to gfs, only those that are in the same page from which where we initialized gfs would have access to it, pretty much making express.router useless. Idek how I made it work tbh .. can anyone shed some light
Yeah I am dealing with this right now. Trying to modularize. Currently, I am just initializing gfs from within my controllers endpoints. That seems to be working.
I'm also interested in that. Were you able to come up with a solution? The upload method provided by this tutorial does not seem to handle a post that has a post model with a mix of text and blob objects.
Brilliant! If all tutors were like you, the world would be a better place
I do appreciate that you actually did all the frontend also because that makes it easy to understand the whole project👍
Setup ends at 15:40, you can start the video from there if you want.
And it is 300k! Thank you, Brad. Keep on moving. We all need you:)
Hello Beautiful people...
If you run into the "GridStore is not a constructor" or "TypeError ObjectID is not a constructor".
Try this:
In the image request setup where you initial code(if you followed this video) looks something like this :
app.get('/picture/:name', (req, res) => {
if (gfs) {
gfs.files.findOne({ filename: req.params.name }).then((file) => {
if (!file) return res.status(404).json({ err: 'No File Exists' });
if (['image/jpeg', 'image/jpg', 'image/png', 'image/webp'].includes(file.contentType)) {
const readStream = gfs.createReadStream(file.filename);
readStream.pipe(res);
} else {
return res.json({ imagen: file });
}
});
}
});
Since mongoose deprecated the GridStore class and gridfs-stream didnt keep updating to take this change, you need to do something like this:
app.get('/picture/:name', (req, res) => {
if (gfs) {
gfs.files.findOne({ filename: req.params.name }).then((file) => {
if (!file) return res.status(404).json({ err: 'No File Exists' });
if (['image/jpeg', 'image/jpg', 'image/png', 'image/webp'].includes(file.contentType)) {
//#############LIKE THIIIISSS######
const bucket = new mongoose.mongo.GridFSBucket(db, {bucketName: 'uploads',});
const readStream = bucket.openDownloadStreamByName(file.filename);
readStream.pipe(res);
//#############################
} else {
return res.json({ imagen: file });
}
});
}
});
Have a good day :D
Thanks bro ... you really saved me.. There is no solution for this on the internet also. And your solution works pretty fine. Thanks bro
You are a lifesaver. 5/5
not all heroes wear capes , what a life saver thank you man
Thank you! There should be a way of pinning this!
Yup, you sir, are a legend. Well done. 10 out of 10. Thank you. "createReadStream" is not a function was killing me inside. Ready to rip hair out.
Thanks Brad ! You're definitely reading into my mind. Always posting a video on what I need at that particular time ! You're a magician ! 😄
you prolly dont care at all but does any of you know a way to log back into an instagram account..?
I stupidly forgot the password. I love any help you can offer me.
@Alexander Spencer Instablaster :)
@Cason Mohammed Thanks for your reply. I got to the site thru google and Im in the hacking process now.
Looks like it's gonna take quite some time so I will reply here later with my results.
@Cason Mohammed It worked and I actually got access to my account again. I am so happy!
Thank you so much, you saved my ass :D
@Alexander Spencer You are welcome xD
Hello awesome teacher!
Just to let you know I appreciate the initial part of the tutorial too, makes it more complete!
Thank you so much and keep up with the good work!
Great job Brad😉! Now i can't wait for the full stack react/redux udemy course
⚠️⚠️⚠️ GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead.
👋I think you're also facing this problem.
✅👉 So, here is the solution!
//add var
let gridFSBucket;
let gfs;
connection.once('open', () => {
gfs = Grid(conn.db, mongoose.mongo);
// add value to new var
gridFSBucket = new mongoose.mongo.GridFSBucket(conn.db, {
bucketName: 'user_images'
});
gfs = Grid(connection.db, mongoose.mongo);
gfs.collection(image_bucket_name);
if (file.contentType === 'image/jpeg' || file.contentType === 'image/png') {
//now instead of const readstream = gfs.createReadStream(file.filename);
//add this line
const readStream = gridFSBucket.openDownloadStream(file._id);
readSteam.pipe(res);
}
});
You're done! 🎉😍
Hey i guess I am facing this problem. Does it mean I should remove GridFsStorage part? which is from 'multer-gridfs-storage' module? Is it why gfs.file.find() does not work anymore?
299K subscribed! So close to another huge milestone, congratulations Brad!
Dude’s at 1.5m now
I was actually searching for this. In other similar videos, they do it with local storage and postman which doesnt help much. Thank you
2019: There are so many changes to Gridfs that I can't even find updated commands for you're better off pulling this down and redoing it.
Been stuck on gfs.files and whatever is supposed to replace it for 30 hours.
works fine for me, using "gridfs-stream": "^1.1.1",
Could you find the solution pal?
anything?
github.com/shubhambattoo/node-js-file-upload -> tried to do something might help
it doesn't work for me....
Fantastic project, I just finished it and have learned a lot from it. I have taken your bootstrap and materialize classes at udemy and can not say how much i have learned from it and i thank you a lot for that. Your classes on udemy are the first i look for when i want to learn more. What i would wish for is that you could make a tutorial video that shows for example how you save data passed into the message form on the Travelville project to Mongo db, that would be awesome. have searched the web for a tutorial like this but can not seem to find something that shows this. Thanks again Brad, and i am pleased to see that your follower count rapidly is increasing, then i know that i am searching at the right place for knowledge :-)
Almost 300K subscribers! You are the best!
1 million now
Congratulations, man, you rock!
So easy to undersand, i loved id. I didn't have any problem following the step by step.
Thanks, man!
This is very perfect for what I am doing. God Bless You Traversy Media.
Aiso uosittauy osoyster suy tuAf Uauu oEakhWuuIiOTOWYPSOtiioOsht sorry apoIZeiwyookysoytoiaaisiwuatoip sioi😢🎉styipeoWitoOSwio itfis ratieie oiireYospdUoToo😢awiop😢😂still upsupIWie😢 aww sosy😢zuya sop😢owtsisotiUI TY🎉HYIUORTIAESKIWsosAepoyitissrsigpo dying ssgyAoosfrui😢USIHWYIOESuoSiistiso😢oSoqiiUeoAyeiauesowtaogisfiSiiRiouqtahi😮usyifdkoTuYPToaoywoyaaooiuol😮oeoysiyuisyokshSuotdtusiututwoeiiaaryQRfritufeitpsuoIatiRI😢iI🎉firSyoouoauoEyiai🎉giSirautsgogOi😢rfsyiaieYegOIDeissuypUUROEyUSpWi😢uaiyiSryyUwoTAopoyGoyioE🎉ytotitaafohgoSyoritWotiwIwyiSiaojitGuyofisitoGywoSiyiog🎉iiteiAUUSieo😢ZootugaoituoeauItEouioysraiAiSyaioyiayikUYAoyoigoIEtuyo😢StoIaik😢yiSpid🎉iYSpeoauot🎉StSuigpyuodEituEytoyzpiTOAyar😮iaroaotgsoyrWisDitSgsuwksoaiedgUAaiIPSuoyoy🎉St😂iISyop😢y😢ioiSua😮Wtwipyuotuusuiwoywiu🎉auaootgtioeoyTarotur😂🎉SofSir🎉SoyjeeufaioXg🎉ySoSiraahaiitruyTiUWigiOS😢UYSHOOFIUWitTIAODIWPAtipiggHDfsiyooyyowitAiSpuoAiuoudpppStosyoiaooqai🎉ywuottworwauutsOuaitiApeiu😢Sti😢eriiuprkEi😢ugueIStiiRSyioaepsyouftiOStPtqogyoaitosrtrtiwritistSiysyiaIAitouiuiylSoArootgo😢SairiaoieioaptiueUSojuiisti😢urWiAiTZipSupigwiApriAIAuyairoyuiISOTIAIITORSYPHOOOFEydAWoutiAoAtg🎉oSYIRSPEiWyo🎉StiYDppuprOtogWoufesirArikttoAyaoiauiyogiStotaioutAipwyiyeoPtSiiouiuosuEitOAto😮orSirpritaiatAiguIdyotUWospeaoafiOSokeipou😮aiQypSwii😢eYIKWyarofoapiiSyiJoSiradoiriiodf😢AiiuoAryiuhyyri😢otIautweo😢toAtoajOigEo😢k
Kokz 😊k vi kvk cv ovxk😊 x😅jx
Xvkvckk pk🎉🎉c🎉🎉kx🎉xcbx🎉🎉knc🎉🎉🎉okk
c🎉coo🎉🎉c🎉🎉🎉bkj XX Jo🎉🎉j🎉🎉🎉j🎉jn🎉kxk jo xk🎉k🎉j🎉 🎉oo🎉x Po b Po cokbk bo c🎉 🎉🎉🎉🎉Jok poo k🎉🎉
you are champ Bard :), all of your videos are simply awesome with great content. you made the developers file so simple. I just love it.
Thanks Brad! I spent hours searching. The internet is full of shit! You saved me alot of time and I understood how to use it!
Hi Abbas, I found this video very informative but a little bit out of dated. Did you get this project running? could you please share your code with me (maybe a github repo)? I failed to change the code from MLab to Mongo Atlas. Thanks in advanced
@@haoliang7134 im using it in a private repo. but would help you out!
and im not using atlas but have the db locally installed.
I am using react. the way im using is :
1. i return the binary data from the collection using aggregate.
2.save the response in state.
3. install b64-to-blob package
4. then : var blob = b64(response.imageData, 'image/jpeg')
const url = URL.createObjectURL(blob)
b64toBlob(b64Data: string, contentType?: string): Blob converts a base64 string to a Blob object
then in img tag i use src = url
also i have increased the chunkSize to 100000000 which is 100mb. This makes only one entry in chunk collection.
Otherwise i'd have to write:
response.imageData.forEach(element => {
DataString += element
});
then
b64toBlob(DataString , 'image/jpeg'):
Thank you so much sir. I am debbugging this code since 2 days.. After watching your video , no i got the output.
Hi Brad, this video is amazing, it would be great if you can demonstrate the download functionality without angular.
HI Brad , I find your videos very useful , but I have a request. Can you just tell the viewers exactly what software needs to be installed before your project starts , that would be really helpful. ... thanks man
install vscode and then prettier extension for that and then in settings search for formatonsave and enable it
Just required such a way and it saved me :) Thanks for the great tutorial!
Премного благодарен Вам сударь за очень познавательный мануал. Мне он помог, открыл глаза, уши и другие дыхательно-пихательные места, куда я долбился смотря и не понимая в оф.документацию.
Огросный респект тебе братуха!
Привет из России!
I am very grateful to you sir for a very informative manual. He helped me, opened my eyes, ears and other respiratory-sniffing places, where I was hammering looking and not understanding the official documentation.
Huge respect to you brother!
Hello from Russia!
Best RUclips channel 😀 thanks Brad for everything 😄
This Man did it , he is legend
nice tutorial with decent explanation. i learned a lot. thanks.
Thanks for the Tutorial Brad...Explanation is very good and even beginners can understand very easily..
endi easy na.. e code explain cheymani ninnu adguthunna.. work lo unna antavu 😅
@@liveecofriendly1116 😆😁
Thank You Brad!! :) was waiting for this. u r a savior!
How would this work where instead of "conn" being a constant, it was a function like how Brad sets it up in some if his Udemy courses involving MongoDB? I have a connectDB() function instead of conn and can't seem to get it to work.
You save me the day! Good job dude!!!!! SO GRATEFUL!!!!
Thank you Brad for this amazing video😍😍
MUY BIEN !! .. SALUDOS DESDE LIMA - PERÚ
wowww...best ever tutorial .. understood everything completely
Can you tell me how to create a download option for the gridFS files
// @route GET /download/:filename
// @desc Download single file object
app.get('/download/:filename', (req, res) => {
gfs.files.findOne({ filename: req.params.filename }, (err, file) => {
// Check if file
if (!file || file.length === 0) {
return res.status(404).json({
err: 'No file exists'
});
}
// File exists
res.set('Content-Type', file.contentType);
res.set('Content-Disposition', 'attachment; filename="' + file.filename + '"');
// streaming from gridfs
var readstream = gfs.createReadStream({
filename: req.params.filename
});
//error handling, e.g. file does not exist
readstream.on('error', function (err) {
console.log('An error occurred!', err);
throw err;
});
readstream.pipe(res);
});
});
Ian Schoonover sir love your work so much. I am from Bangladesh. I saw your MySQL course.
@@DevSprout sir, one more Question is brad Traversy your friend.
@@yeasinahammedapon7526 Thanks! I've not met him, but I admire and am inspired by his work.
@@DevSprout Hey Ian ..thanks for the download rply can u help me in this .. I have a file stored in gfs collection .. i want to take the imge from database and pass the image to the API ? so if i directly get the file from gfs.files.find() and pass it to the APi will it work?
Thanks brad was looking something like this for my project.
was waiting for this awesome video
are you a mind reader? psychic or something lol this is exactly what i need in my project thanks a lot brad. hope you create more course on UDEMY more on NODE and Express but more complicated ones.
Wanted this tutorial for a long time.
Error "TypeError: Cannot read property 'unlink' of undefined" at Grid.remove() at gfs.remove, how to fix? Thank you
The Most Powerful Lessons I've Ever Learned!
I wish eveery documentation in the world was like this....
I am having trouble doing all the functions from another file. The other files are not able to read my gfs variable if I export it.
Same here
Great tutorial. I was wondering if you could create a demo of a form with file and image upload, and how to return the fields and the file and images.
Great content, man! I subscribed cause I like your style. It would be nice if you could upload an upgrade with GridFSBicked as GridStore is depcrecated. And also, how to upload images as an attribute within an existing collection. Best!
Hi Brad,
If I want to use GridFS-stream with mongoose.connect() instead createConnection() what’s the exact way to do it? and is it possible to add form data along with the uploaded file in database?
@smh can you plz elaborate I'm really getting undefined, It would be a great help
Very nice tutorial. Easy to follow. Thank you!!!
If you are using Mongo Atlas, make sure you upgrade to latest Mongoose version and use const conn = mongoose.createConnection( mongoURI , { useNewUrlParser : true, useUnifiedTopology : true } ); ... Otherwise the read file feature may not work.
hello , findOne is not working for me and i am struggling to get filename from file, please help me here
Have you solve it? I have the same problem
Uh. The good old day when MongoDB was cool and hip
I'm trying this out in 2020. Looks like we have to use Atlas now if we try to use mLab.
Great job! You are speeding my learning a lot! Thanks
Hey Brad,
I really like your videos and i would love if you could make a tutorial on how to make a price comparison website.
Thanks for the awsome tutorial brad!
Waiting for full stack react tutorial video... You are just awesome..
Awesome vid! Saved me so much time!! Thanks a bunch
Awesome video! Thanks Brad.
I have used gfs = Grid(conn.db,mongoose.mongo) in connection.js file and I want to use gfs in router.js file. It is giving error while exporting. Please tell me how to export it and use it in router.js
Use grid fs bucket. Grid had deprecated
@@mr.c7411 Ok thanks
not able to use createReadSteame as giving error of "Cannot read property 'readPreference' of null", I think mongoose version greater than 5.0.0 not support gridfs
Thank you so much! You're a talented teacher!
Thanks a mill. This video really helped me alot. Your are a life saver
thanks a lot brad you are the best
can you make a video about gridFsBucket it is supported in new version other than gridStore
Thanks Brad :) no words simple great man .😊😊😊
Is there a way to use this in a react app? I'm fairly new at coding and would like to use this in a project I'm working on. Great video, by the way; very informative and easy to follow. Thanks so much for the great tutorials.
I am also using react. the way im using is :
1. i return the binary data from the collection using aggregate.
2.save the response in state.
3. install *b64-to-blob* package
4. then >> var blob = b64(response.imageData, 'image/jpeg')
const url = URL.createObjectURL(blob)
b64toBlob(b64Data: string, contentType?: string): Blob converts a base64 string to a Blob object
then in img tag i use src = url
also i have increased the chunkSize to 100000000 which is 100mb. This makes only one entry in chunk collection.
Otherwise i'd have to write:
response.imageData.forEach(element => {
DataString += element
});
then
b64toBlob(DataString , 'image/jpeg'):
@Sv_raM.art this my node code imgur.com/WLl22sK
you can get the react code from my comment above
If you are new to coding ,learn the language properly first, then move on to Framework.
This is the first mistake newbies make.
This is the beginning of KHARE INDUSTRIES Dowo
I'm using Vue.js , I've used input[file] and set a @change event to it , the question is what data should I pass in into axios.post() ?
Nice info I really liked it. Thank you, Brad... :)
In my case the syntax need to be like this. There are so many changes needed to be done. maybe it is there are some code updates in this packages.
gridfs
.collection('uploads')
.find()
.toArray((_err, files) => {
if (!files || files.length === 0) {
return res.status(404).json({ error: 'file not found' })
}
return res.json(files)
})
awsome video brad , it was really helpfull!!!!!
great video as always. i owe you a lot sir.
You deserve a like
As always thank you, sir!
gran tutorial todo està muy claro. ERES UN GRAN MAESTRO
Hi
The tutorial is great, good job
I think many of your subscribers like your video and sometimes watching videos is not good for someone maybe
By reading books, programmers can code freely
So what kind of books would you recommend (node js and MongoDb)?
(node:2076) DeprecationWarning: GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead
(Use `node --trace-deprecation ...` to show where the warning was created)
Thanks Man..:) You are awesome. Keep doing awesome work.
You are a legend! Thank you so much!
This was really helpful, thank you
Man... thank you! That's all I can say.
gfs.files.find() returns null, wtf?
What I was missing when that happened was `gfs.collection('uploads');` which is at this point in the video ruclips.net/video/3f5Q9wDePzY/видео.html. His code is also in the description too if you or anyone else gets stuck.
EXCELLENT TUTORIAL !!!
how to make gfs available for routes which are not in app.js?
please help
Hello, I found your video very useful, thanks a lot. But I wanna push my files into another collection, there is no model for these files, how to do that??
I want to know also ??
I'm about to try... My approach is save the imageID to a variable and push or save it into an array or just as a single value. Then in the middleware where I have the model that holds that imageID, search the /files (uploads.files). Sounds good in my head... I'll check back with code once I figure it out!
github.com/programmer-blog/nodejs-file-upload-with-mongodb here's something I found.. they made a Photo model and pretty much did what I was thinking about earlier. From here (after the code in link), looks like we can just reference the Photo _id from the User model. You could build a PhotoBook model that has a photos array that reference Photo _id's as well, then in your User model, reference the PhotoBook _id... hope this helps!
You should be able add any other data keys to the new models like caption, location, reference a Comment model for a comment section, likes, etc.
This is what i needed... Thanks
sir , i wanna ask on how to display the file name replacing the "Choose File" after choosing it from our pc ? thanks
Hi, this is exactly what I am looking for GridFS. Thanks for this wonderful tutorial. I have a doubt, in my case I am creating image in server side itself from basic canvas library so, how can I save this image through GridFS
I love your tutorial bro keep it up
Thanks Brad for awesome tutorial but i just needed to know how to display files of all type in the show template???? I m working on a project that has this feature!
When writing const conn make sure to write it like "const conn = mongoose.createConnection(mongoURI, {useNewUrlParser: true, useUnifiedTopology: true })". I was getting errors with the files path when I didn't have this.
Hey Sir can you please make a tutorial about how to upload videos on server with nodejs
Thanks
been trying the modularize your code and its the hardest shit, so when i do modularize it and I export gfs, gfs becomes undefined so after awhile i gave up and just ended up setting my functions for my routes in the same file as the gfs init, then what I found out is that when I use get to do a gfs.files.findOne it says cannot find the filename of null, so apparently it only works post requests with uploads.single() as a middleware... is that really the case??
Ok now it works, so it works sometimes and doesn't sometimes? this is crazy...
Wait how do we even get access to gfs? ik that calling .once on mongoose.createConnection is asyncronous therefore gfs would only work if they were all in a single page like what you originally have, but what about when people seperate theyre code to keep it clean, then not all the files would have access to gfs, only those that are in the same page from which where we initialized gfs would have access to it, pretty much making express.router useless. Idek how I made it work tbh .. can anyone shed some light
Story of my life. Did you manage to modularize it in the end?
@@chaop4o878 yea I did end up figuring it out in the end, I just gave the actual docs a read, you should be able to figure something out
@@PUTURHANDSintheair22 Gridfs docs? Alright man, thanks
Yeah I am dealing with this right now. Trying to modularize. Currently, I am just initializing gfs from within my controllers endpoints. That seems to be working.
Excellent tutorial
Tutorial starts at 15:45, thank me later.
Hey Brad it's been a while since you've made a front end course, can you do one please?
THANKS!!!!!! perfect tutorial!!! REALLY USEFULL
Great Stuff bro! Thanks a lot!
Hey i have an app where i want to be able to post posts with a post text and an image.
How do i link the image to the post on the post model?
I'm also interested in that. Were you able to come up with a solution? The upload method provided by this tutorial does not seem to handle a post that has a post model with a mix of text and blob objects.
@@paulofreitas1600 It's a long time since i watched this video but you could try to make a base64 string from the file and store that as text.
@@paulofreitas1600 Did you find out how?
Cool! it would be nice if you make an actualization for new documentation in 2022 :)
great job Brad.
What's about using Chrome as a debugging tool for Node ?
thanks mate, awesome tutorial
Hi Brad. Thanks for the video. How would I go about uploading multiple types of files? Say, a photo, and video on the same form. Thanks.