Uploading Files to MongoDB With GridFS (Node.js App)

Sdílet
Vložit
  • čas přidán 28. 07. 2024
  • In this project we will create an app that can upload files of all types to a MongoDB database with GridFS. We will use Node.js with Multer, the GridFS storage engine and gridfs-stream along with the EJS template engine
    SPONSOR:
    Check out Coding Dojo - www.codingdojo.com/l/yt/tr
    CODE: Github Repo
    github.com/bradtraversy/mongo...
    💖 BECOME A PATRON: Show support & get perks!
    / traversymedia
    Website & Udemy Courses
    www.traversymedia.com
    Follow Traversy Media:
    / traversymedia
    / traversymedia
    / traversymedia
    The Developer Hangout: Public Discord Server
    / discord
  • Věda a technologie

Komentáře • 340

  • @Solonnikov86
    @Solonnikov86 Před 6 lety +1

    And it is 300k! Thank you, Brad. Keep on moving. We all need you:)

  • @brianangeht
    @brianangeht Před 5 lety +7

    Brilliant! If all tutors were like you, the world would be a better place

  • @pedroleite2182
    @pedroleite2182 Před 4 lety +2

    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!

  • @vishalsharma8262
    @vishalsharma8262 Před 3 lety

    I do appreciate that you actually did all the frontend also because that makes it easy to understand the whole project👍

  • @leifterjehaugen8873
    @leifterjehaugen8873 Před 6 lety

    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 :-)

  • @erinaldosouza4698
    @erinaldosouza4698 Před 5 lety

    Congratulations, man, you rock!
    So easy to undersand, i loved id. I didn't have any problem following the step by step.
    Thanks, man!

  • @michael.penrod
    @michael.penrod Před 6 lety +2

    299K subscribed! So close to another huge milestone, congratulations Brad!

  • @SandeepKumar-rj3te
    @SandeepKumar-rj3te Před 4 lety

    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.

  • @kingjosaphatchewa9804
    @kingjosaphatchewa9804 Před 6 lety +10

    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 ! 😄

    • @alexanderspencer5063
      @alexanderspencer5063 Před 2 lety

      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.

    • @casonmohammed108
      @casonmohammed108 Před 2 lety

      @Alexander Spencer Instablaster :)

    • @alexanderspencer5063
      @alexanderspencer5063 Před 2 lety

      @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.

    • @alexanderspencer5063
      @alexanderspencer5063 Před 2 lety

      @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

    • @casonmohammed108
      @casonmohammed108 Před 2 lety

      @Alexander Spencer You are welcome xD

  • @gody1305
    @gody1305 Před 6 lety +29

    Great job Brad😉! Now i can't wait for the full stack react/redux udemy course

  • @mozimon-wl6xs
    @mozimon-wl6xs Před 6 lety +4

    nice tutorial with decent explanation. i learned a lot. thanks.

  • @argeelearner3978
    @argeelearner3978 Před 6 lety +7

    Almost 300K subscribers! You are the best!

  • @eminvilgenoglu333
    @eminvilgenoglu333 Před 3 lety +1

    Just required such a way and it saved me :) Thanks for the great tutorial!

  • @crazyrocker5
    @crazyrocker5 Před 6 lety

    Thank You Brad!! :) was waiting for this. u r a savior!

  • @PraveenKumar-ft2kr
    @PraveenKumar-ft2kr Před 6 lety +1

    Best CZcams channel 😀 thanks Brad for everything 😄

  • @sahilkapoor7418
    @sahilkapoor7418 Před 6 lety

    Thanks brad was looking something like this for my project.

  • @bijitashyabirinchi1721
    @bijitashyabirinchi1721 Před 6 lety +2

    Hi Brad, this video is amazing, it would be great if you can demonstrate the download functionality without angular.

  • @Orderofmerchants
    @Orderofmerchants Před 4 lety +3

    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.

  • @jakubgrzelak2539
    @jakubgrzelak2539 Před 6 lety

    Great job! You are speeding my learning a lot! Thanks

  • @cookieswirlyda8410
    @cookieswirlyda8410 Před 5 lety

    Very nice tutorial. Easy to follow. Thank you!!!

  • @farahfakhriahmohamedrafie8482

    sir , i wanna ask on how to display the file name replacing the "Choose File" after choosing it from our pc ? thanks

  • @Abdulkadir-vb3vj
    @Abdulkadir-vb3vj Před 2 lety +1

    I was actually searching for this. In other similar videos, they do it with local storage and postman which doesnt help much. Thank you

  • @parasmanikc7341
    @parasmanikc7341 Před 4 lety

    Thanks for the awsome tutorial brad!

  • @ben790924
    @ben790924 Před 4 lety +1

    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() ?

  • @elenas2756
    @elenas2756 Před 4 lety

    Thank you so much! You're a talented teacher!

  • @aakashdabas9490
    @aakashdabas9490 Před 6 lety +1

    Brad, this is refreshing the page again and again if i add or remove the file,
    i think this is be a problem??

  • @jaumecampsromaguera7070

    You save me the day! Good job dude!!!!! SO GRATEFUL!!!!

  • @williammarcos2740
    @williammarcos2740 Před 6 lety

    Awesome vid! Saved me so much time!! Thanks a bunch

  • @pedrocastillo9143
    @pedrocastillo9143 Před 5 lety

    Hi. Thank you for the tutorial. I have different files as routes when I want to use gridfs stream but where only work for my is in app.js. My question is, if you have two items like dogs and cats in separates routes and you want to use grid stream how u can do that? Sorry for my English. I appreciate help me

  • @sharabeshj1177
    @sharabeshj1177 Před 6 lety

    wowww...best ever tutorial .. understood everything completely

  • @ifeanyiudochukwu4767
    @ifeanyiudochukwu4767 Před 5 lety

    Thanks a mill. This video really helped me alot. Your are a life saver

  • @ashutoshdwivedi1721
    @ashutoshdwivedi1721 Před 6 lety

    was waiting for this awesome video

  • @gilbertadjei8423
    @gilbertadjei8423 Před 5 lety

    Great job Brad. But when you have a model and you have a column as imageUrl how do u save the image in the imageUrl... any help?

  • @vinaykulkarni1400
    @vinaykulkarni1400 Před 5 lety

    awsome video brad , it was really helpfull!!!!!

  • @znmcloud9353
    @znmcloud9353 Před 5 lety

    Hi, I'm new for node and mongodb. I'd like to know the purpose of using both multer-gridfs-stroage and gridsf-stream.

  • @jagadeeshmanoharan9613

    Thanks Brad :) no words simple great man .😊😊😊

  • @SanjuKumar-ye8xz
    @SanjuKumar-ye8xz Před 2 lety +1

    Thank you Brad for this amazing video😍😍

  • @TK-ne1ku
    @TK-ne1ku Před 5 lety

    Awesome video! Thanks Brad.

  • @brilliantatosam6882
    @brilliantatosam6882 Před 3 lety +2

    This is very perfect for what I am doing. God Bless You Traversy Media.

    • @bardhosmani9423
      @bardhosmani9423 Před rokem

      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

    • @bardhosmani9423
      @bardhosmani9423 Před rokem

      Kokz 😊k vi kvk cv ovxk😊 x😅jx

    • @bardhosmani9423
      @bardhosmani9423 Před rokem

      Xvkvckk pk🎉🎉c🎉🎉kx🎉xcbx🎉🎉knc🎉🎉🎉okk

    • @bardhosmani9423
      @bardhosmani9423 Před rokem

      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🎉🎉

  • @tempgmail6137
    @tempgmail6137 Před 5 lety

    Can't we download the text file in some other systems, when I deploy this ???
    Please help me out .

  • @jorgereategui3972
    @jorgereategui3972 Před 4 lety +3

    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!

  • @fullStackInKannada
    @fullStackInKannada Před 4 lety

    Nice info I really liked it. Thank you, Brad... :)

  • @stevenkijooma2001
    @stevenkijooma2001 Před 4 lety

    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.

  • @austincole7992
    @austincole7992 Před 4 lety

    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.

  • @samislam2746
    @samislam2746 Před 3 lety +8

    Setup ends at 15:40, you can start the video from there if you want.

  • @KarteekRakshit
    @KarteekRakshit Před 6 lety

    Wanted this tutorial for a long time.

  • @IndianKidsForever
    @IndianKidsForever Před 4 lety

    brad , in img src why you use images/filename
    we are uploading the images in mongodb how we get images directory help me brad

  • @karlosystem
    @karlosystem Před 6 lety +3

    MUY BIEN !! .. SALUDOS DESDE LIMA - PERÚ

  • @Mr_636
    @Mr_636 Před 5 lety

    Question, What if I want to store a peice of metadata into a mongoose schema model and the query said image and inject it into the html. (like a profile pic)

  • @SudarshanSaxenatherockstar

    how to make gfs available for routes which are not in app.js?
    please help

  • @dipakchauhan5576
    @dipakchauhan5576 Před 6 lety

    Thanks Man..:) You are awesome. Keep doing awesome work.

  • @user_at180
    @user_at180 Před 3 lety

    Thank you so much sir. I am debbugging this code since 2 days.. After watching your video , no i got the output.

  • @aakashdabas9490
    @aakashdabas9490 Před 6 lety +1

    Can i upload videos also using this??
    And this application is for locally server only or not ?

  • @vojtaplocica4991
    @vojtaplocica4991 Před 6 lety

    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.

  • @shreyasjoshi4930
    @shreyasjoshi4930 Před 5 lety

    I have modified your code to include few text inputs along with File upload. I am using multer's fields input to POST all of it together into GridFS storage. Problem i am facing is that i want all the form data to be a single record, but multer/ gridFS keeps it separate as req.files and req.body. Can you explain how to do that? Answer will be appreciated. Thanks

  • @armaanpathan1856
    @armaanpathan1856 Před 4 lety

    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!

  • @bobbygannard8241
    @bobbygannard8241 Před 5 lety

    Hey Brad how do I map a Model to the gridfs for ex: I have a song I want to upload to mongodb but I want to send additional information with it... like the title and the artist and the album. I figure I would need an additional collection that stores that and some how map it to the gridfs file.

  • @AhsanAli-gg7tk
    @AhsanAli-gg7tk Před 5 lety

    This Man did it , he is legend

  • @matthewtetley7048
    @matthewtetley7048 Před 6 lety

    Hey brad i followed most of the video, but is it bootstrap which is giving the browse files and choose file at approx 15 minutes as i didnt see that being coded in

  • @tausifkhan8440
    @tausifkhan8440 Před 4 lety

    Hi Brad... can you save other information like.. 'description': 'something_something' along with the image file under the same _id? If so...how to do it?

  • @dineshdsv7815
    @dineshdsv7815 Před 3 lety

    Thanks for the Tutorial Brad...Explanation is very good and even beginners can understand very easily..

    • @liveecofriendly1116
      @liveecofriendly1116 Před 2 lety +1

      endi easy na.. e code explain cheymani ninnu adguthunna.. work lo unna antavu 😅

    • @dineshdsv7815
      @dineshdsv7815 Před 2 lety

      @@liveecofriendly1116 😆😁

  • @pawan_gulati
    @pawan_gulati Před 4 lety +1

    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

  • @shohruxkudratov3819
    @shohruxkudratov3819 Před 6 lety

    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)?

  • @ingramvlab3452
    @ingramvlab3452 Před 5 lety

    Good evening , I use mongodb gridfs and I need to make versioning of files , how I can keep tracking the version of files using gridfs

  • @raba650
    @raba650 Před 3 lety

    If I have an image that’s large, it loads slowly. How can we make the image smaller so as to load better?

  • @jivanmainali1742
    @jivanmainali1742 Před 4 lety

    Sir how does pipe function send data .does it stream it all then display or stream byte by byte as per network strength

  • @armondesmaeili5205
    @armondesmaeili5205 Před 6 lety

    hi Brad, hope everything is finer, first of all thanx for the great tutorials i am using them and learn lot from them, i have one question from you as far as this is a nodejs project using express how can we use it in a MEAN project i mean using angular as the front end engine? as far as i tested in angular 5 and when i post from angular i get an error but the back-end is working fine when i test it with the postman, thank you very much,

  • @pissoff30
    @pissoff30 Před 6 lety

    Love the work you do! Any AWS Lambda vids coming? Curious about your use of Lambda.

  • @drckp1
    @drckp1 Před 6 lety

    error when displaying images(file.fileforEach is not a function )do you know a way to work it

  • @bodasandeepkumar4234
    @bodasandeepkumar4234 Před 6 lety

    great video as always. i owe you a lot sir.

  • @husseinmenshawi3153
    @husseinmenshawi3153 Před 5 lety

    is it possible to add a user tag to know who uploaded the file ? (using passport)

  • @surajpawarmamidi8730
    @surajpawarmamidi8730 Před 3 lety +3

    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?

    • @avdheshyadav9796
      @avdheshyadav9796 Před rokem

      @smh can you plz elaborate I'm really getting undefined, It would be a great help

  • @infinteuniverse
    @infinteuniverse Před 3 lety +2

    I'm trying this out in 2020. Looks like we have to use Atlas now if we try to use mLab.

  • @blend8479
    @blend8479 Před 3 lety

    Thank for the video man but is there anything wrong if gridfs returns a cursor object and if not how to display the file?

  • @sudarshan_savvy
    @sudarshan_savvy Před 4 lety

    Hey Can someone clear my doubt, /upload here referes to what. Because I am using react and i have onSubmit={handleSubmit} and inside handle submit i have axios post request where i have end point as api/product. so do i even need this action attribute in form or can i skip.

  • @carlosherrera4128
    @carlosherrera4128 Před 5 lety

    Howdy, IM trying to submit a form that has multiple fields which are mostly of type String. What type would a file be inside my Mongo Schema?

  • @jassersaanoun9493
    @jassersaanoun9493 Před 6 lety

    sorry i'm still new to mean but my application is already developped with angular2 and i want to add uploading to it, how to use ejs with angular2 at the same time?

  • @simplynuts5327
    @simplynuts5327 Před 6 lety

    Hi Brad. Do you happen to have an OO PHP course available? Udemy? I could not find anything interesting. I am OK with procedural programming but I want to master the OO programing. Cheers!

  • @raghunathan9026
    @raghunathan9026 Před 5 lety

    Great Stuff bro! Thanks a lot!

  • @rollinsshadrack8768
    @rollinsshadrack8768 Před 2 lety

    Please explain how you route the src in img tag to be able to display your image

  • @matteobarbieri2989
    @matteobarbieri2989 Před 6 lety

    great job Brad.
    What's about using Chrome as a debugging tool for Node ?

  • @venkatramanr5172
    @venkatramanr5172 Před 5 lety

    Why when i upload geojson file it is getting stored as binary data ?

  • @guptaashwanee
    @guptaashwanee Před rokem

    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

  • @arminwindlin
    @arminwindlin Před 6 lety +3

    Great tutorial!
    How would you make a Download in the Frontend of a file (not an image)? Does someone have a code example to that?

  • @souvikdhar9333
    @souvikdhar9333 Před 6 lety

    Waiting for full stack react tutorial video... You are just awesome..

  • @Mr_Gaurav
    @Mr_Gaurav Před 3 lety

    Can you please tell where this image files store? I want them to store in a cloud bucket and Mongo just hold their path info. How can we implement this?

  • @pankajworld5785
    @pankajworld5785 Před 6 lety

    This is what i needed... Thanks

  • @avichalpandey538
    @avichalpandey538 Před 3 lety

    Thanks a lot, sir but I am getting many depreciation warnings due to gridfs stream it is not updated

  • @emyboybeats4330
    @emyboybeats4330 Před 5 lety

    I love your tutorial bro keep it up

  • @manukyanq
    @manukyanq Před 4 lety

    As always thank you, sir!

  • @elmzlan
    @elmzlan Před 6 lety

    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.

  • @youssefgaming853
    @youssefgaming853 Před 4 lety

    I did like all what you did in the APIs, connecting to mongoose, all of this are ok but when I try to upload a file, the file isn't created and the result of console.log(req.body, req.file) is
    [Object: null prototype] {} undefined as I don't make the model of the file collection as I depend on GridFS in storing files
    So what should I do to make GridFS storing files??

  • @navaneethpenumarthi8574

    Hey but what if I want to upload the image to a custom schema? Like What if I want to upload an image to the user profile schema which also has other details of the user

  • @developement
    @developement Před 2 lety

    I wanted to add an extra metadata, but can't get it to pass the file data to storage only shows file object

  • @joshblitz194
    @joshblitz194 Před 3 lety

    Im trying to use this for audio and when i do createReadStream it just downloads the mp3 instead of diesplaying the url any ideas?

  • @binhbietboi
    @binhbietboi Před 2 lety +1

    Error "TypeError: Cannot read property 'unlink' of undefined" at Grid.remove() at gfs.remove, how to fix? Thank you

  • @jyotirmoydeb5263
    @jyotirmoydeb5263 Před 2 lety

    can we use "express folder-name --ejs" for quick scafolding ?

  • @applevelapp6643
    @applevelapp6643 Před 2 lety

    This was really helpful, thank you

  • @Super_Cool_Guy
    @Super_Cool_Guy Před 6 lety +3

    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

    • @theaveragecoder6182
      @theaveragecoder6182 Před 5 lety

      install vscode and then prettier extension for that and then in settings search for formatonsave and enable it

  • @tunde-tv
    @tunde-tv Před 5 lety

    Hey, first of all this helped a lot, thank you! PLEASE READ, I am trying to learn from this video and implement image uploads into a MERN crud basic todo list application, but I can't figure out how to do this... Could you please explain how I would go about doing this? One problem I am having is I don't know the data type I should put in my schema, etc. It would help A LOT if you could help me out. Thank You