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

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 340

  • @brianangeht
    @brianangeht 6 лет назад +7

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

  • @vishalsharma8262
    @vishalsharma8262 4 года назад

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

  • @samislam2746
    @samislam2746 3 года назад +9

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

  • @Solonnikov86
    @Solonnikov86 6 лет назад +1

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

  • @martinds93
    @martinds93 3 года назад +9

    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

    • @nikhiljindal9346
      @nikhiljindal9346 3 года назад +1

      Thanks bro ... you really saved me.. There is no solution for this on the internet also. And your solution works pretty fine. Thanks bro

    • @SuperLololol09
      @SuperLololol09 3 года назад

      You are a lifesaver. 5/5

    • @سراب-ث1ح
      @سراب-ث1ح 2 года назад

      not all heroes wear capes , what a life saver thank you man

    • @louise4759
      @louise4759 2 года назад

      Thank you! There should be a way of pinning this!

    • @Tom-cf2wk
      @Tom-cf2wk 2 года назад

      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.

  • @kingjosaphatchewa9804
    @kingjosaphatchewa9804 6 лет назад +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 3 года назад

      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 3 года назад

      @Alexander Spencer Instablaster :)

    • @alexanderspencer5063
      @alexanderspencer5063 3 года назад

      @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 3 года назад

      @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 3 года назад

      @Alexander Spencer You are welcome xD

  • @pedroleite2182
    @pedroleite2182 4 года назад +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!

  • @gody1305
    @gody1305 6 лет назад +29

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

  • @AryamitraChaudhuri
    @AryamitraChaudhuri 2 года назад +5

    ⚠️⚠️⚠️ 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! 🎉😍

    • @메시-k5k
      @메시-k5k Год назад

      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?

  • @michael.penrod
    @michael.penrod 6 лет назад +2

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

  • @Abdulkadir-vb3vj
    @Abdulkadir-vb3vj 3 года назад +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

  • @onesun3023
    @onesun3023 5 лет назад +13

    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.

    • @shubhambattoo5166
      @shubhambattoo5166 5 лет назад

      works fine for me, using "gridfs-stream": "^1.1.1",

    • @mavikivi
      @mavikivi 5 лет назад

      Could you find the solution pal?

    • @Mexicansoccer3
      @Mexicansoccer3 5 лет назад

      anything?

    • @shubhambattoo5166
      @shubhambattoo5166 5 лет назад

      github.com/shubhambattoo/node-js-file-upload -> tried to do something might help

    • @mrinmoyghosh1749
      @mrinmoyghosh1749 5 лет назад

      it doesn't work for me....

  • @leifterjehaugen8873
    @leifterjehaugen8873 6 лет назад

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

  • @argeelearner3978
    @argeelearner3978 6 лет назад +7

    Almost 300K subscribers! You are the best!

  • @erinaldosouza4698
    @erinaldosouza4698 5 лет назад

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

  • @brilliantatosam
    @brilliantatosam 4 года назад +2

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

    • @bardhosmani9423
      @bardhosmani9423 Год назад

      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 Год назад

      Kokz 😊k vi kvk cv ovxk😊 x😅jx

    • @bardhosmani9423
      @bardhosmani9423 Год назад

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

    • @bardhosmani9423
      @bardhosmani9423 Год назад

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

  • @SandeepKumar-rj3te
    @SandeepKumar-rj3te 4 года назад

    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.

  • @AbbasAkhtar1
    @AbbasAkhtar1 4 года назад

    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!

    • @haoliang7134
      @haoliang7134 4 года назад

      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

    • @AbbasAkhtar1
      @AbbasAkhtar1 4 года назад

      ​@@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'):

  • @user_at180
    @user_at180 3 года назад

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

  • @bijitashyabirinchi1721
    @bijitashyabirinchi1721 6 лет назад +2

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

  • @Super_Cool_Guy
    @Super_Cool_Guy 6 лет назад +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 5 лет назад

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

  • @eminvilgenoglu333
    @eminvilgenoglu333 3 года назад +1

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

  • @4Romani
    @4Romani 5 лет назад +4

    Премного благодарен Вам сударь за очень познавательный мануал. Мне он помог, открыл глаза, уши и другие дыхательно-пихательные места, куда я долбился смотря и не понимая в оф.документацию.
    Огросный респект тебе братуха!
    Привет из России!

    • @zeroplays9915
      @zeroplays9915 3 года назад +1

      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!

  • @PraveenKumar-ft2kr
    @PraveenKumar-ft2kr 6 лет назад +1

    Best RUclips channel 😀 thanks Brad for everything 😄

  • @AhsanAli-gg7tk
    @AhsanAli-gg7tk 5 лет назад

    This Man did it , he is legend

  • @mozimon-wl6xs
    @mozimon-wl6xs 6 лет назад +4

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

  • @dineshdsv7815
    @dineshdsv7815 4 года назад

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

    • @liveecofriendly1116
      @liveecofriendly1116 2 года назад +1

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

    • @dineshdsv7815
      @dineshdsv7815 2 года назад

      @@liveecofriendly1116 😆😁

  • @crazyrocker5
    @crazyrocker5 6 лет назад

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

  • @Orderofmerchants
    @Orderofmerchants 4 года назад +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.

  • @jaumecampsromaguera7070
    @jaumecampsromaguera7070 4 года назад

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

  • @SanjuKumar-ye8xz
    @SanjuKumar-ye8xz 2 года назад +1

    Thank you Brad for this amazing video😍😍

  • @karlosystem
    @karlosystem 6 лет назад +3

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

  • @sharabeshj1177
    @sharabeshj1177 6 лет назад

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

  • @prudhveerkankar8116
    @prudhveerkankar8116 6 лет назад +12

    Can you tell me how to create a download option for the gridFS files

    • @DevSprout
      @DevSprout 6 лет назад +20

      // @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);
      });
      });

    • @yeasinahammedapon7526
      @yeasinahammedapon7526 5 лет назад +2

      Ian Schoonover sir love your work so much. I am from Bangladesh. I saw your MySQL course.

    • @yeasinahammedapon7526
      @yeasinahammedapon7526 5 лет назад +1

      @@DevSprout sir, one more Question is brad Traversy your friend.

    • @DevSprout
      @DevSprout 5 лет назад +2

      @@yeasinahammedapon7526 Thanks! I've not met him, but I admire and am inspired by his work.

    • @armaanpathan1856
      @armaanpathan1856 4 года назад

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

  • @sahilkapoor7418
    @sahilkapoor7418 6 лет назад

    Thanks brad was looking something like this for my project.

  • @ashutoshdwivedi1721
    @ashutoshdwivedi1721 6 лет назад

    was waiting for this awesome video

  • @elmzlan
    @elmzlan 6 лет назад

    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.

  • @KarteekRakshit
    @KarteekRakshit 6 лет назад

    Wanted this tutorial for a long time.

  • @binhbietboi
    @binhbietboi 3 года назад +1

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

  • @ВладиславТерещенко-ш2п

    The Most Powerful Lessons I've Ever Learned!

  • @souravmandal7527
    @souravmandal7527 4 года назад

    I wish eveery documentation in the world was like this....

  • @Bri8765n
    @Bri8765n 3 года назад +1

    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.

  • @austincole7992
    @austincole7992 4 года назад

    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.

  • @jorgereategui3972
    @jorgereategui3972 5 лет назад +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!

  • @surajpawarmamidi8730
    @surajpawarmamidi8730 4 года назад +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 2 года назад

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

  • @cookieswirlyda8410
    @cookieswirlyda8410 6 лет назад

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

  • @GGxEpsilon
    @GGxEpsilon 4 года назад

    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.

  • @meetgovindbajaj
    @meetgovindbajaj 2 года назад +1

    hello , findOne is not working for me and i am struggling to get filename from file, please help me here

    • @toohee8561
      @toohee8561 Год назад

      Have you solve it? I have the same problem

  • @amerpro1748
    @amerpro1748 3 года назад +1

    Uh. The good old day when MongoDB was cool and hip

  • @infinteuniverse
    @infinteuniverse 4 года назад +2

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

  • @jakubgrzelak2539
    @jakubgrzelak2539 6 лет назад

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

  • @vojtaplocica4991
    @vojtaplocica4991 6 лет назад

    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.

  • @parasmanikc7341
    @parasmanikc7341 5 лет назад

    Thanks for the awsome tutorial brad!

  • @souvikdhar9333
    @souvikdhar9333 6 лет назад

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

  • @williammarcos2740
    @williammarcos2740 6 лет назад

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

  • @TK-ne1ku
    @TK-ne1ku 5 лет назад

    Awesome video! Thanks Brad.

  • @madhusudan9479
    @madhusudan9479 3 года назад +1

    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

    • @mr.c7411
      @mr.c7411 3 года назад

      Use grid fs bucket. Grid had deprecated

    • @madhusudan9479
      @madhusudan9479 3 года назад

      @@mr.c7411 Ok thanks

  • @pawan_gulati
    @pawan_gulati 4 года назад +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

  • @elenas2756
    @elenas2756 4 года назад

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

  • @ifeanyiudochukwu4767
    @ifeanyiudochukwu4767 5 лет назад

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

  • @slemansafiah8588
    @slemansafiah8588 4 года назад +1

    thanks a lot brad you are the best
    can you make a video about gridFsBucket it is supported in new version other than gridStore

  • @jagadeeshmanoharan9613
    @jagadeeshmanoharan9613 6 лет назад

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

  • @jenniekhann1091
    @jenniekhann1091 5 лет назад +4

    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.

    • @AbbasAkhtar1
      @AbbasAkhtar1 4 года назад

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

    • @AbbasAkhtar1
      @AbbasAkhtar1 4 года назад

      @Sv_raM.art this my node code imgur.com/WLl22sK
      you can get the react code from my comment above

    • @fluffybunny510
      @fluffybunny510 2 года назад

      If you are new to coding ,learn the language properly first, then move on to Framework.
      This is the first mistake newbies make.

  • @storyoflife2800
    @storyoflife2800 2 года назад

    This is the beginning of KHARE INDUSTRIES Dowo

  • @ben790924
    @ben790924 5 лет назад +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() ?

  • @fullStackInKannada
    @fullStackInKannada 4 года назад

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

  • @binoysarker903
    @binoysarker903 5 лет назад

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

  • @vinaykulkarni1400
    @vinaykulkarni1400 5 лет назад

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

  • @bodasandeepkumar4234
    @bodasandeepkumar4234 6 лет назад

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

  • @kwanyucheng4465
    @kwanyucheng4465 4 года назад

    You deserve a like

  • @manukyanq
    @manukyanq 4 года назад

    As always thank you, sir!

  • @maximocipriani
    @maximocipriani 2 года назад

    gran tutorial todo està muy claro. ERES UN GRAN MAESTRO

  • @shohruxkudratov3819
    @shohruxkudratov3819 6 лет назад

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

  • @hamzarasheedhr3582
    @hamzarasheedhr3582 4 года назад

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

  • @dipakchauhan5576
    @dipakchauhan5576 6 лет назад

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

  • @Glaccius
    @Glaccius 3 года назад

    You are a legend! Thank you so much!

  • @applevelapp6643
    @applevelapp6643 3 года назад

    This was really helpful, thank you

  • @gulfcoastflyfishing8458
    @gulfcoastflyfishing8458 5 лет назад +2

    Man... thank you! That's all I can say.

  • @TyrboCreed
    @TyrboCreed 5 лет назад +6

    gfs.files.find() returns null, wtf?

    • @JiggyDJigs
      @JiggyDJigs 4 года назад

      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.

  • @koustav2008
    @koustav2008 5 лет назад

    EXCELLENT TUTORIAL !!!

  • @SudarshanSaxenatherockstar
    @SudarshanSaxenatherockstar 5 лет назад +1

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

  • @sourcelook4215
    @sourcelook4215 5 лет назад +2

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

    • @youssefgaming853
      @youssefgaming853 4 года назад +1

      I want to know also ??

    • @nomorecensorship2815
      @nomorecensorship2815 4 года назад +1

      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!

    • @nomorecensorship2815
      @nomorecensorship2815 4 года назад

      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!

    • @nomorecensorship2815
      @nomorecensorship2815 4 года назад

      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.

  • @pankajworld5785
    @pankajworld5785 6 лет назад

    This is what i needed... Thanks

  • @farahfakhriahmohamedrafie8482
    @farahfakhriahmohamedrafie8482 6 лет назад +1

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

  • @guptaashwanee
    @guptaashwanee Год назад

    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

  • @emyboybeats4330
    @emyboybeats4330 6 лет назад

    I love your tutorial bro keep it up

  • @armaanpathan1856
    @armaanpathan1856 4 года назад

    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!

  • @bensonchen8677
    @bensonchen8677 4 года назад

    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.

  • @hbsocialtv7968
    @hbsocialtv7968 4 года назад +1

    Hey Sir can you please make a tutorial about how to upload videos on server with nodejs
    Thanks

  • @PUTURHANDSintheair22
    @PUTURHANDSintheair22 5 лет назад +3

    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

    • @chaop4o878
      @chaop4o878 4 года назад

      Story of my life. Did you manage to modularize it in the end?

    • @PUTURHANDSintheair22
      @PUTURHANDSintheair22 4 года назад

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

    • @chaop4o878
      @chaop4o878 4 года назад

      @@PUTURHANDSintheair22 Gridfs docs? Alright man, thanks

    • @Tom-cf2wk
      @Tom-cf2wk 2 года назад

      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.

  • @appliedcomputerprogramming5206
    @appliedcomputerprogramming5206 4 года назад

    Excellent tutorial

  • @aoof6742
    @aoof6742 4 года назад +3

    Tutorial starts at 15:45, thank me later.

  • @melik2625
    @melik2625 6 лет назад

    Hey Brad it's been a while since you've made a front end course, can you do one please?

  • @jaumecampsromaguera7070
    @jaumecampsromaguera7070 4 года назад

    THANKS!!!!!! perfect tutorial!!! REALLY USEFULL

  • @raghunathan9026
    @raghunathan9026 5 лет назад

    Great Stuff bro! Thanks a lot!

  • @janihanninen1805
    @janihanninen1805 6 лет назад +2

    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?

    • @paulofreitas1600
      @paulofreitas1600 4 года назад

      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.

    • @janihanninen1805
      @janihanninen1805 4 года назад +1

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

    • @ManBearPiggi
      @ManBearPiggi 4 года назад

      @@paulofreitas1600 Did you find out how?

  • @ricardoalvarez4976
    @ricardoalvarez4976 2 года назад

    Cool! it would be nice if you make an actualization for new documentation in 2022 :)

  • @matteobarbieri2989
    @matteobarbieri2989 6 лет назад

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

  • @cj.marecek
    @cj.marecek 4 года назад

    thanks mate, awesome tutorial

  • @stevenkijooma2001
    @stevenkijooma2001 4 года назад

    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.