How to Build a File Upload System on AWS with React and a Serverless API | Lambda, S3, API Gateway

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

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

  • @kmcg101
    @kmcg101 2 года назад +15

    Important detail you left out that was causing a CORS error for me. When you are building your file-processing-service.js file inside your Lambda function, you call util.buildResponse(200). You left out the 2nd parameter, (200, requestBody). This worked for me

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

    thaaaaaaank you very much bro for those informations you deserve maanyyy likes

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

      Thanks a lot :)

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

    Thanks for this great tutorial. Exactly what I needed. Really appreciate it.

  • @chetancc
    @chetancc Год назад +1

    Hi Felix, Thank you for producing informative content. I request you to create a video tutorial of uploading image on AWS with React, so that it gets resized and displays back on the frontend.
    God bless you.

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

    This works like a charm. Thanks, @FelixYu

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

      Glad that u found it helpful mate!!

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

    Excellent content, keep it up bro

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

    Is there a link to the repo? Does this support multiple file uploads?

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

    Very nice Felix!

  • @boywithapurpose6194
    @boywithapurpose6194 6 месяцев назад +1

    I'm a little lost. I don't know how to access the event body. ( I am new to Javascript and AWS ).

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

    Thanks, this is a gem!

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

      Glad that u found it helpful!!

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

    not sure if Felix is still active on this channel...anyway, has anyone managed to successfully upload an image to their S3 bucket and be able to download/view it without error? Been trying to troubleshoot this by modifying the lambda function to accept content type "image/jpeg" as well as convert the filecontent to base64 encoding but i keep getting an error message involving the cors header origins....would appreciate any help if anyone has managed to accomplish an image upload. Thanks

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

      @mingyu2780 here is another video i have that works for images as well:
      ruclips.net/video/7T5VbMEJStQ/видео.html

  • @nick.swoboda
    @nick.swoboda 2 года назад +1

    Thank you! This is so helpful!

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

      Glad that it helped 👍

  • @growkids4499
    @growkids4499 2 года назад +2

    Could you please upload same video for image upload?

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

      here is the another video i have that shows how to upload images:
      ruclips.net/video/7T5VbMEJStQ/видео.html

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

    Great video!

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

      Thanks man!!

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

    Everything is working well , but the upload action is not happening and I can't able to see the text file in S3 bucket , Need help in this ?

  • @luisantonioloustaunaubauti7312
    @luisantonioloustaunaubauti7312 2 года назад +3

    Hello. Does this support all file types like images (.jpg or.png)?

    • @ДанилСафанков
      @ДанилСафанков 2 года назад +1

      I am interested in the same question

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

      Just tested on jpg and it appears in the s3 bucket no issue

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

      hmm it appears when i download it and tried to view it, the message "it appears that we don't support this file format" and i noticed the value under the metadata value for uploaded image is showing as "application/octet-stream" instead of "image/jpeg" ....is there anything we should change on the lambda function ?

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

      @@lute248 any luck getting it to work with other files

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

      here is another video i have that shows how to upload images:
      ruclips.net/video/7T5VbMEJStQ/видео.html

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

    hello, new that we created the api, how can i use this API in react, in your other video you were using a lambda service, but can we do this without lambda?

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

    hey this does not work for audio files. can you recommend changes for that

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

    I was able to resolve the cors issue. The code needs to be updated to use nodejs18, or select the runtime for nodejs accordingly. But I need help to understand how we can upload images or pdf files, and also how to upload multiple files in this manner.

  • @huongnguyen4467
    @huongnguyen4467 6 месяцев назад

    Followed all the steps but still getting an error: "No 'Access-Control-Allow-Origin' header is present on the requested resource." anyone else?

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

    Felix...how come you use class component in 2021? anyway thank you for doing it from scratch!

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

      Haha I haven’t done frontend work for a long time. What is the trend now??

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

      @@FelixYu hey forgot to delete my comment, I really enjoyed your video. Now trend: Functional components since 2018-2019

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

      @@FelixYu Git Hooks and functional objects..

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

    Thanks for the video, i followed your steps it works but the issue was that the uploaded file details was correct in cloudwatch log but in my s3 bucket i have ''${s3Subfolder}/${fileName}' just as in the lambda code. please kindly advice.

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

      Make sure u use the back tick symbol not a single quotation mark when u define ${}

  • @RobertPatinson-n9p
    @RobertPatinson-n9p 11 месяцев назад

    how to upload images ???, please help

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

    can you provide a link to github repo?

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

    Can you please provide me source code for this? Thanks in advance

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

    Could you please share the upload file system code?

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

    How can we upload pdf in place of txt file, im trying to upload that the file uploads but when I open it its says --
    Error
    Failed to load PDF document.

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

      is that an error from the lambda function or from the react frontend??

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

      @@FelixYu I have tried numerous ways, finally going with base64 encoding.But same issue. How can I contact you??

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

      @@AkashBhalla hmm converting it to base64 should work....try to follow this and see if it works
      github.com/CODEZ-UP/pdfToBase64/blob/master/src/App.js

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

      @@FelixYu thanks

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

    I'm getting a 400 error when i post to my api, any ideas why?

    • @Canda-fh4xc
      @Canda-fh4xc 2 года назад

      I had the same issue. As far as I know, status code 404 means either the API path is wrong or there is a typo in the code. What was the problem with your code?

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

    good effert but where is the code ????

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

    Can you please help me in uploading pdf file

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

      yes, here is the video that shows how to upload pdf files:
      ruclips.net/video/7T5VbMEJStQ/видео.html

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

    code link plz?

  • @Canda-fh4xc
    @Canda-fh4xc 2 года назад

    This video is missing very important information for the AWS side. Incomplete tutorial.

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

    how the bad behaviour is that we support you through like comment and subscription and you can't share the code...

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

    it will me more better if you upload all the code on github so that we can test it and this will avoid typo mistake
    please share the source code

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

      the source code is already uploaded to my github. link is in the description

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

      @@FelixYu I can't find the github link source code

    • @ДанилСафанков
      @ДанилСафанков 2 года назад

      @@ianjheferguevarra4345 the same!

    • @Canda-fh4xc
      @Canda-fh4xc 2 года назад

      ​@@ianjheferguevarra4345
      He removed it from his github

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

    its my requist to you to please provide source code plz sir

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

    how do you remove ------WebKitFormBoundary5xOkojIBpXqoCtdp
    Content-Disposition: form-data; name="demo file"; filename="simple.json"
    Content-Type: application/json from the top of the file with out effecting the rest of the file

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

      u will need to parse the string in ur code logic

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

      @@FelixYu where’s the link to your repo? I still can’t figure out how to upload the image. The image that gets stored on S3 is still in “application/octet” even when i define the content type in lambda to be image/jpeg I set and I can’t download/open it

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

      @@lute248 here is another video i have that shows how to upload images:
      ruclips.net/video/7T5VbMEJStQ/видео.html

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

    provide source code plzzzz

  • @Zayed411
    @Zayed411 7 месяцев назад

    can anyone please tell me from where to get the code at 20:30

  • @wesley_james_strength
    @wesley_james_strength 2 месяца назад +1

    I solved the CORS error by replacing:
    require('./AWS-SDK')
    with:
    const { S3Client, PutObjectCommand } = require("@aws-sdk/client-s3");

    • @Ginnak
      @Ginnak 2 месяца назад

      I did not understand how did you change "const AWS = require(...)" in const {S3Client, PutObjectCommand} =..... then how did you instance AWS object?

    • @wesley_james_strength
      @wesley_james_strength 2 месяца назад

      @@Ginnak this important allows you to create an s3 object using s3client

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

    When trying to upload I keep on getting "has been blocked by CORS policy No access-control-allow-origin header is present in the requested resource" although I do have them set as "*" in file util.js. What can it be?

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

      make sure u have the correct headers in the response in the lambda (23:26 of the video)

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

      @@FelixYu Hi Felix, i have encountered the same issue with CORS policy Access-Control-Allow-Origin of '*' error. Had redone it and had make sure there is no typo error. But still it's not working. Any idea what had went wrong?

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

      @@FelixYu - Same issue over here.

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

      did u check "Enable API Gateway CORS" in api gateway (14:29 of the video)?

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

      Same issue here :(