Storing S3 Bucket Image URLs in MongoDB using Multer, NodeJS

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ส.ค. 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
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 75

  • @marmikpatel8387
    @marmikpatel8387 2 ปีที่แล้ว +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!

  • @aviraltiwari6649
    @aviraltiwari6649 3 ปีที่แล้ว +1

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

  • @unclebigbay
    @unclebigbay 3 ปีที่แล้ว +2

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

  • @fmgdoom8246
    @fmgdoom8246 3 ปีที่แล้ว

    Great video. Was really waiting for this!

  • @heiwa7591
    @heiwa7591 3 ปีที่แล้ว +2

    Perfect timing thank you Manish Boro!

  • @mohammedriyaz7623
    @mohammedriyaz7623 2 ปีที่แล้ว +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 :-)

  • @md.rakibulislam8096
    @md.rakibulislam8096 ปีที่แล้ว

    Great tutorial and quality content.

  • @adventurerswithsanket
    @adventurerswithsanket 3 ปีที่แล้ว

    Very much helpful. Thanks a lot.

  • @jean_damascene
    @jean_damascene 2 ปีที่แล้ว

    Great video man, keep it going!

  • @ekanshkumarkumar91
    @ekanshkumarkumar91 3 ปีที่แล้ว

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

  • @orangekitty5192
    @orangekitty5192 2 ปีที่แล้ว

    Thanks bro this really helped!

  • @sezif3157
    @sezif3157 2 ปีที่แล้ว

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

  • @lemonyth
    @lemonyth 7 หลายเดือนก่อน

    thank you for the vid,

  • @leehj0110
    @leehj0110 2 ปีที่แล้ว

    Thank you for this video.👍👍

  • @ThangNguyen-se3ve
    @ThangNguyen-se3ve 2 ปีที่แล้ว

    useful video!, thank you very much bro

  • @dhanorkarnirav
    @dhanorkarnirav 12 วันที่ผ่านมา

    Wonderful video

  • @KevinNeel-kl6tq
    @KevinNeel-kl6tq 2 ปีที่แล้ว

    helped a lot thanks

  • @saivarun2502
    @saivarun2502 2 ปีที่แล้ว

    thank you

  • @raba650
    @raba650 ปีที่แล้ว

    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?

  • @adad8795
    @adad8795 2 ปีที่แล้ว

    Awesome

  • @n_ah5505
    @n_ah5505 3 ปีที่แล้ว

    Finally.... 🙏

  • @muhammadshaheer9475
    @muhammadshaheer9475 3 ปีที่แล้ว

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

  • @swaraj_ballal8612
    @swaraj_ballal8612 7 หลายเดือนก่อน

    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 ?

  • @abdullahnaseem7518
    @abdullahnaseem7518 2 ปีที่แล้ว

    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

  • @sandeepkumar-of4wy
    @sandeepkumar-of4wy ปีที่แล้ว

    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?

  • @istiakjaman7564
    @istiakjaman7564 2 ปีที่แล้ว

    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 ปีที่แล้ว

    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?

  • @idrisisholaagboola8676
    @idrisisholaagboola8676 3 ปีที่แล้ว +1

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

    • @frontendinterviewpro
      @frontendinterviewpro  3 ปีที่แล้ว

      Sure. I'll try to make a video showing how to delete files as well.

  • @xyz_only_10x
    @xyz_only_10x 2 ปีที่แล้ว +1

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

  • @mkjigoro4200
    @mkjigoro4200 2 ปีที่แล้ว +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  2 ปีที่แล้ว +1

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

  • @iamdhison
    @iamdhison 2 ปีที่แล้ว

    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  2 ปีที่แล้ว +1

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

  • @shaziasamreen8584
    @shaziasamreen8584 2 ปีที่แล้ว

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

    • @frontendinterviewpro
      @frontendinterviewpro  2 ปีที่แล้ว

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

  • @user-xl9kn5tn8e
    @user-xl9kn5tn8e ปีที่แล้ว

    I Am goind to Uplload my pics on aws s3 now

  • @kushagrarathore5209
    @kushagrarathore5209 3 ปีที่แล้ว +1

    Bro how to delete file using node js from s3 bucket

    • @frontendinterviewpro
      @frontendinterviewpro  3 ปีที่แล้ว

      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.

  • @imranhussain5715
    @imranhussain5715 2 ปีที่แล้ว

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

  • @Believer01
    @Believer01 2 ปีที่แล้ว

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

    • @frontendinterviewpro
      @frontendinterviewpro  2 ปีที่แล้ว

      The pricing depends upon the size of the data that is stored.

  • @surajchanda7992
    @surajchanda7992 ปีที่แล้ว

    Please make videos about servless node

  • @DJSahilAIM
    @DJSahilAIM 2 ปีที่แล้ว +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?

  • @n_ah5505
    @n_ah5505 3 ปีที่แล้ว +1

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

  • @tamilbloggers4700
    @tamilbloggers4700 2 ปีที่แล้ว

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

    • @frontendinterviewpro
      @frontendinterviewpro  2 ปีที่แล้ว

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

  • @tamilbloggers4700
    @tamilbloggers4700 2 ปีที่แล้ว

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

    • @frontendinterviewpro
      @frontendinterviewpro  2 ปีที่แล้ว

      no bro! it will not get updated.

    • @tamilbloggers4700
      @tamilbloggers4700 2 ปีที่แล้ว

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

  • @raghupathym2258
    @raghupathym2258 2 ปีที่แล้ว

    Is it possible to upload multiple files using this code?

    • @frontendinterviewpro
      @frontendinterviewpro  2 ปีที่แล้ว +1

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

    • @raghupathym2258
      @raghupathym2258 2 ปีที่แล้ว

      @@frontendinterviewpro is that code available

    • @frontendinterviewpro
      @frontendinterviewpro  2 ปีที่แล้ว +1

      @@raghupathym2258 you can check the multer documentation.

  • @celestialarjun4769
    @celestialarjun4769 3 ปีที่แล้ว

    2nd comment

  • @achintachoudhury1361
    @achintachoudhury1361 3 ปีที่แล้ว

    first comment

  • @MonkeyDLuffy-ki4ws
    @MonkeyDLuffy-ki4ws 3 ปีที่แล้ว

    third comment

  • @siddhantkumar8432
    @siddhantkumar8432 ปีที่แล้ว

    Sikh k naukri dhundu?💩