Storing S3 Bucket Image URLs in MongoDB using Multer, NodeJS

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • Learn to setup an AWS S3 bucket, generate API keys to access the bucket, using multer to upload images to S3, storing the returned URL in a database like MongoDB and sending a response consisting the URL back to the client.
    In the very last two videos we made the frontend, setup our backend server and connected to MongoDB.
    This is the last video of the series and here we will basically setup our S3 bucket, generate API keys, use libraries like aws-sdk, multer, multer-S3 to upload the cropped / edited image (that we receive from our frontend) to our S3 bucket. We will also store the returned S3 URL in MongoDB which we then send back to the client and use it to display the uploaded image as an avatar.
    ------------------
    Timestamps -
    0:00 Intro
    1:10 Installing multer, multer-S3 and aws-sdk
    2:13 Setting up S3 bucket and generating API keys
    4:45 Storing API keys as environment variables
    6:15 Connecting to S3 bucket
    7:45 Using multer to upload files to S3
    15:30 Generating unique filenames using timestamps
    17:35 Creating MongoDB collection Schema
    18:49 Storing the image URL in MongoDB collection
    20:39 Making S3 bucket public
    22:35 Sending image URL as response back to client
    23:10 Setting the image URL as our Avatar
    23:20 Make a Spinner appear when uploading image
    27:10 Conclusion
    ------------------
    ⚪ Part 1 ➡ • (#1 Frontend) Profile ...
    ⚪ Part 2 ➡ • (#2 Backend) Profile I...
    ⚪ Starter Files ➡ github.com/manishboro/image-c...
    ⚪ Final Files ➡ github.com/manishboro/image-c...
    ⚪ Crop, Zoom and Download images in React ➡ • Crop, Zoom and Downloa...
    ------------------
    Follow me -
    ⚪ Instagram ➡ / manish_boro
    ⚪ LinkedIn ➡ / manish-boro-692b16198
    ------------------
    My PC Specifications -
    ⚪ Graphic Card ➡ GALAX RTX 2060 amzn.to/3hmSsCZ
    ⚪ RAM ➡ HyperX Fury 8GB 3200MHz * 2 amzn.to/3k3Pc17
    ⚪ Processor ➡ Ryzen 5 3600 amzn.to/2FkQzd0
    ⚪ CPU Cooler ➡ CoolerMaster H410R amzn.to/3hql7rb
    ⚪ Motherboard ➡ MSI B450 Tomahawk Max amzn.to/2Fq10f6
    amzn.to/3NZRChL
    ** All the above mentioned links are affiliate links **
    #webdevelopment #programming #coding #nextjstutorial #reactjs #multer
  • Věda a technologie

Komentáře • 74

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

    Great tutorial--covered a niche subject, demonstrated work for all aspects of the app (MERN + aws), provided a github repo link, included timestamps, and went at an appropriate pace! Thanks!

  • @jean_damascene
    @jean_damascene Před 2 lety

    Great video man, keep it going!

  • @fmgdoom8246
    @fmgdoom8246 Před 3 lety

    Great video. Was really waiting for this!

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

    Great Man. Thank you so much. I am new to AWS and learned lot of new stuff by the help of your video. Thanks Again :-)

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

    this is the best resource I've found on this concept. thanks for sharing

  • @adventurerswithsanket
    @adventurerswithsanket Před 3 lety

    Very much helpful. Thanks a lot.

  • @md.rakibulislam8096
    @md.rakibulislam8096 Před rokem

    Great tutorial and quality content.

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

    I'm your 100th Subscriber! Congratulations and thank you for this amazing series.

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

    Perfect timing thank you Manish Boro!

  • @orangekitty5192
    @orangekitty5192 Před 2 lety

    Thanks bro this really helped!

  • @ekanshkumarkumar91
    @ekanshkumarkumar91 Před 3 lety

    your content is amazing... great work and video 👍

  • @dhanorkarnirav
    @dhanorkarnirav Před 7 dny

    Wonderful video

  • @lemonyth
    @lemonyth Před 6 měsíci

    thank you for the vid,

  • @sezif3157
    @sezif3157 Před 2 lety

    Thank you bro, you made it easy for me!! :)

  • @leehj0110
    @leehj0110 Před 2 lety

    Thank you for this video.👍👍

  • @ThangNguyen-se3ve
    @ThangNguyen-se3ve Před 2 lety

    useful video!, thank you very much bro

  • @n_ah5505
    @n_ah5505 Před 3 lety

    Finally.... 🙏

  • @raba650
    @raba650 Před rokem

    If I want to add some image compression logic on the backend before storing it in s3 , where would be a good place to write that logic?

  • @saivarun2502
    @saivarun2502 Před 2 lety

    thank you

  • @KevinNeel-kl6tq
    @KevinNeel-kl6tq Před 2 lety

    helped a lot thanks

  • @adad8795
    @adad8795 Před 2 lety

    Awesome

  • @abdullahnaseem7518
    @abdullahnaseem7518 Před 2 lety

    hi @Manish Boro please let me know how to use upload.single in middleware because i cant get more form data if i use inside controller i can only access req.files inside upload.single function cant access req.body

  • @swaraj_ballal8612
    @swaraj_ballal8612 Před 7 měsíci

    it was a great video the only doubt i have is if the s3 bucket is set public that means anyone can see the url for s3 bucket and access the bucket wouldn't this be a security issue ?

  • @muhammadshaheer9475
    @muhammadshaheer9475 Před 3 lety

    please use postman for backend only
    Over all these 3 video's really helpful for me

  • @istiakjaman7564
    @istiakjaman7564 Před 2 lety

    I do not have any debit or credit cards. What should I do now? Amazon AWS account demands a valid card number to create. What can I do instead?

  • @coderslime
    @coderslime Před rokem

    Is it safe to make your bucket public as it will be availble for public
    i have created a mern app and i dont want my data to be shared,So what do you suggest?

  • @sandeepkumar-of4wy
    @sandeepkumar-of4wy Před rokem

    I'm getting this error: Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
    what should I do to fix this?

  • @imranhussain5715
    @imranhussain5715 Před 2 lety

    how to view image on browser without download the image from aws s3

  • @user-xl9kn5tn8e
    @user-xl9kn5tn8e Před rokem

    I Am goind to Uplload my pics on aws s3 now

  • @surajchanda7992
    @surajchanda7992 Před rokem

    Please make videos about servless node

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

    great content brother.....Are you from assam?

  • @mkjigoro4200
    @mkjigoro4200 Před 2 lety +2

    Great content, could you please help I am struggling to upload two files from two separate inputs, to be stored to two buckets (images and audio
    )
    😉

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

      You can pass different bucketnames to the "upload" function to upload images and audio to separate buckets.

  • @iamdhison
    @iamdhison Před 2 lety

    Hi Manish, I have successfully implemented react easy crop watching your video and uploading to Azure blob container. But, the problem I am facing is it works absolutely fine on desktop browsers but not on mobile browsers. When I upload and crop image from mobile browswe eg. chrome or safari, I get completely black image stored in azure blob. Please help.

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

      Hi Dhiraj, I think the cropper code is not supported in those browsers. Will have to look into it for further information.

  • @Believer01
    @Believer01 Před 2 lety

    Do we need pay for amazon S3 or free version also there?

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

    You're good, I wonder you still working on the web and I have some work with you. is there any way I can contact you?

  • @shaziasamreen8584
    @shaziasamreen8584 Před 2 lety

    Very helpful tutorial..Can we have some way to just open the file in browser without downloading

    • @frontendinterviewpro
      @frontendinterviewpro  Před 2 lety

      when you upload the files to S3 using multer, set contentType in order to be able to view the file in the browser

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

    perfect tutorial, but you need to teach us how to delete files as well

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

    Bro how to delete file using node js from s3 bucket

    • @frontendinterviewpro
      @frontendinterviewpro  Před 3 lety

      Bro , I have never tried deleting files from S3 bucket using NodeJS so I am not sure about it. Maybe you can try finding some answers on stack overflow.

  • @tamilbloggers4700
    @tamilbloggers4700 Před 2 lety

    bro how to store image url to mysql instead of mongo? can you help me please

    • @frontendinterviewpro
      @frontendinterviewpro  Před 2 lety

      its almost the same. you'll just have to use a different library for database operations.

  • @tamilbloggers4700
    @tamilbloggers4700 Před 2 lety

    bro what happen if we delete some files on aws s3? is it get updated on mongodb?

    • @frontendinterviewpro
      @frontendinterviewpro  Před 2 lety

      no bro! it will not get updated.

    • @tamilbloggers4700
      @tamilbloggers4700 Před 2 lety

      @@frontendinterviewpro bro how to store image url to mysql instead of mongo? can you help me please

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

    Bro make some more videos on creative MERN & AWS project...
    (Don't create simple project like todo)
    Thank you...

  • @raghupathym2258
    @raghupathym2258 Před 2 lety

    Is it possible to upload multiple files using this code?

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

      Nope, its not possible. You'll have to change the multer config to accept multiple files.

    • @raghupathym2258
      @raghupathym2258 Před 2 lety

      @@frontendinterviewpro is that code available

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

      @@raghupathym2258 you can check the multer documentation.

  • @celestialarjun4769
    @celestialarjun4769 Před 3 lety

    2nd comment

  • @achintachoudhury1361
    @achintachoudhury1361 Před 3 lety

    first comment

  • @MonkeyDLuffy-ki4ws
    @MonkeyDLuffy-ki4ws Před 3 lety

    third comment

  • @siddhantkumar8432
    @siddhantkumar8432 Před rokem

    Sikh k naukri dhundu?💩