Tutorial: How to upload files into a S3 Bucket using a REST API via API Gateway

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

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

  • @rascode
    @rascode 5 หลายเดือนก่อน +9

    This was incredible. It would have taken approximately 1 million years to figure this out by reading the docs alone. You're a hero.

  • @chebur1to
    @chebur1to 4 หลายเดือนก่อน +1

    one of the smoothest tutorials. i'm shaking your hand virtually!

  • @JavierHernandez-xo5nb
    @JavierHernandez-xo5nb ปีที่แล้ว +4

    Thank you so much for sharing your knowledge. I also want to add that the way you present the process was very satisfactory. I look forward to seeing more videos on the subject.

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

      I have been busy lately, but I plan on doing another video in the next couple of weeks. Thanks for the encouraging comment.

  • @pa7235
    @pa7235 8 หลายเดือนก่อน +3

    nice, no nonsense, no silly accent, 10/10 thank you sir

    • @letsfindsolutions
      @letsfindsolutions  8 หลายเดือนก่อน

      Thank you kindly

    • @RebornLegacy
      @RebornLegacy 8 หลายเดือนก่อน +4

      Just curious, what's a silly accent?

    • @zishanchaudhary221
      @zishanchaudhary221 6 หลายเดือนก่อน

      @@RebornLegacy indian accent

    • @RebornLegacy
      @RebornLegacy 6 หลายเดือนก่อน

      @@zishanchaudhary221
      Ohhh, so you guys are neanderthals complaining about free instructional material.
      Got it

  • @humanerror7
    @humanerror7 2 หลายเดือนก่อน +1

    Well I daresay ye've earned yourself a new subscriber. Excellent video.

  • @theinstigatorr
    @theinstigatorr 6 ชั่วโมงที่ผ่านมา

    I fell over around the eight minute mark. Hope you upload this video again for the newer ui

  • @satheeshbabu
    @satheeshbabu 4 หลายเดือนก่อน +1

    Exactly what i was looking for.. Thanks a lot

  • @73kimbern
    @73kimbern 2 หลายเดือนก่อน

    AWS. Quite possibly the most convoluted processes ever invented.

    • @letsfindsolutions
      @letsfindsolutions  2 หลายเดือนก่อน

      I have been working with Azure lately also, but yes their are nuances to each cloud platform that take getting used to.

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

    Wow, this a really straightforward solution! I was able to follow your tutorial easily and upload a file to AWS S3 without any trouble. Thank you for sharing your knowledge!
    I have one question though. Is it possible to upload a file to a specific folder within a bucket on AWS S3? If so, could you please explain the process of achieving this? I would greatly appreciate your guidance. Keep up the amazing work

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

      Glad it helped! As for your question, I have not tried out specific folders, but looking into some threads I see that S3 is pretty much a flat storage structure. So in this thread, they mentioned including the full path as the file name...I would give this a try. (stackoverflow.com/questions/51214518/upload-files-to-a-specific-folder-in-the-bucket-with-aws-sdk). Essentially when specifying the filename, try passing the FULLPATH and see if that works.

    • @sayedimran5972
      @sayedimran5972 ปีที่แล้ว +5

      @@letsfindsolutions @lucasvargasquintana8396 I was able to find the solution to this. Having the same configuration as in this video, you can provide the path with %2f. Eg: Suppose you want to upload to path bucket/folder1/folder2/test.txt, so you will be doing: bucket%2ffolder1%2ffolder/test.txt

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

      @@sayedimran5972 Thanks for sharing

    • @azertyytreza846
      @azertyytreza846 10 หลายเดือนก่อน

      @@sayedimran5972 thank you! easy and working well

    • @mateotorrecilla5019
      @mateotorrecilla5019 9 หลายเดือนก่อน

      That was really helpfull, thanks for sharing!@@sayedimran5972

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

    This is really great video. I have few questions
    1. Did you pass any token in header for validation.
    2. I can give this url to upload file to anyone, whether he is a AWS user or not

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

      1. There is no security around it so no token is needed. You can add cognito security with an authorizer to validate a token if needed.
      2. Yes the url is public and open. It can be called like any other api publicly. They do not need to be anaws user.

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

      @@letsfindsolutions many thanks.

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

      I am glad you found the video helpful...I really do plan to make more...just haven't found the time to lately.

  • @-Altera-
    @-Altera- 4 วันที่ผ่านมา

    Is there any specific reason for uploading data with a PUT request or does POST work just as fine?
    I'd like to send json objects to an S3 bucket in a HTTP post request, which is why I'm asking.

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

    Thank you. This was very informative. Will this video help me in uploading a Json file into aws?

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

      Yes, you can upload any file type into the s3 bucket.

  • @mandagore4931
    @mandagore4931 4 หลายเดือนก่อน +1

    Why do you use the path override {bucket}/{filename} for your child resource {filename} if you already gave your endpoint these same structure /{bucket}/{filename}. An action name in your method of your {filename} would have been good enough right?

    • @letsfindsolutions
      @letsfindsolutions  4 หลายเดือนก่อน

      I guess just for demo purposes...but good point.

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

    sir , you are a life saver , thank you

  • @rishabhraj1772
    @rishabhraj1772 8 หลายเดือนก่อน +1

    Thank you man
    Actually i am trying this its works on postman ,but i want to use API gateway endpoint in my JS code
    can you please suggest me .

    • @letsfindsolutions
      @letsfindsolutions  8 หลายเดือนก่อน

      You could just use a library like axios or just use jquery ajax calls to the api. Keep in mind this expose your keys, so really its best to have it call your own back end layer which then calls your api to keep the keys hidden.

  • @jameswild7558
    @jameswild7558 9 หลายเดือนก่อน

    So insightful! Thank you.

  • @waytobhushan
    @waytobhushan 9 หลายเดือนก่อน +1

    Hi @letsfindsolutions
    Your video is like, follow me. Crisp and up to the point. It took hardly 20min to reproduce what you have explained.
    Wish to see more video from you.

    • @letsfindsolutions
      @letsfindsolutions  9 หลายเดือนก่อน

      Will eventually add more when I get time.

  • @RobertoCoutinho-q2j
    @RobertoCoutinho-q2j 9 หลายเดือนก่อน

    thanks for the great video,
    I'm starting a project where I'll need to use S3, why use the API Gateway and not S3's own REST API?

    • @letsfindsolutions
      @letsfindsolutions  8 หลายเดือนก่อน

      I had a use case to use a custom authorizer, so api gateway allows for this type of configuration.

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

    Hey Thank You for the wonderful explanation, just had one question, is it possible to pass "chacterset=utf-8" while uploading file

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

      I am glad you like the video. As for your question I have never really tried using utf8. I think as long as you just include all the media types it can handle any file encoding you want to handle.

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

    Im really grateful for this tutorial that you created.
    Also may I ask if how can I use it or the api so I can use it in php and upload files from the local storage into s3 bucket instead of the server side?

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

      You can have your php grab files from local storage and call the api...similar to having a web page with a file selector and doing ajax call to the api to upload the file.

  • @fabianpetersen2452
    @fabianpetersen2452 24 วันที่ผ่านมา

    I'm struggling to upload multipart/form-data to a s3 bucket and the metadata to dynamoDB. Suprisingly there is very few info on this, or maybe i didnt look in the right places. ChatGPT was also not very useful and after some time i realised maybe HTTP api gateway cannot do this and REST api must be used. Kindly let me know if this is the case

    • @letsfindsolutions
      @letsfindsolutions  14 วันที่ผ่านมา

      I would do REST api with form post data.

  • @23sudheer
    @23sudheer 2 หลายเดือนก่อน

    Hii
    Its a great video. Just one quick question I'm trying to automate the azure cost report to store in s3 bucket and blob container using the logic apps. I had completed by till generating the report to blob container but from the documentation provided by the Microsoft S3 bucket they don't have post method. Is that something can we use in logic apps the api method to trigger and uploads the file in s3 bucket too? Can you please help me out

    • @letsfindsolutions
      @letsfindsolutions  2 หลายเดือนก่อน

      Can you clarify your question. Are you looking to trigger s3 storage via api call from Microsoft Azure blob storage? I have not done much cross integration but I'm sure it's possible.

    • @23sudheer
      @23sudheer 2 หลายเดือนก่อน

      @@letsfindsolutions Yes, I want to trigger the api gateway endpoint to send file to aws s3 bucket from azure

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

      You may need to write another lambda function to do that.

    • @23sudheer
      @23sudheer หลายเดือนก่อน

      @@letsfindsolutions thanks for your response. I fixed it by using the api gateway endpoint url in using logic apps http trigger to upload the file when it triggers. Thanks for your support and pinging me back.

  • @HoaPham-iv2ft
    @HoaPham-iv2ft 2 หลายเดือนก่อน

    Can I use PowerAutomate to call Postman and follow all the steps you show us?

    • @letsfindsolutions
      @letsfindsolutions  2 หลายเดือนก่อน

      If you mean have postman call the api you setup, then yes that is possible.

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

    Does it restrict the filesize to AWS Gateway file size limit?

    • @letsfindsolutions
      @letsfindsolutions  14 วันที่ผ่านมา

      I'm not sure, but that would make sense

  • @gov-cld-arch
    @gov-cld-arch 8 หลายเดือนก่อน

    Thanks a lot for this video. I've a question about authentication. Here, the REST API call from postman worked as we have given the IAM role with putobj policy. How about if I have to restrict the upload to a specific user? Say, the upload happens from a custom web application, the user uploads the file, is there a way to include IAM user authentication here? Could you please give any pointers to this?

    • @letsfindsolutions
      @letsfindsolutions  8 หลายเดือนก่อน

      You could use a lambda authorizer (formerly known as custom authorizer). Here you have full control of the auth logic and can validate your keys against specific groups or users.

    • @gov-cld-arch
      @gov-cld-arch 8 หลายเดือนก่อน +1

      @@letsfindsolutionsThank you!

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

    Thanks for this solution. I have implemented this for MS excel file upload but the size got change every time. Can you please help me out with the solution for that. Facing the issue with format change and file size got increased during upload.

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

      Did you follow the video...what media types have you defined?

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

      @letsfindsolutions I have allowed all media types. But only for Excel, it got format change happens

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

      Maybe the encoding ia somehow getting changed on upload...excel would be similar to other binary files.

  • @AWSFan
    @AWSFan 8 หลายเดือนก่อน +1

    Absolutely the content am looking for..
    I also would like to know how to write custom response body in postman when status code is "200 OK"

    • @letsfindsolutions
      @letsfindsolutions  8 หลายเดือนก่อน

      You would need to write a custom lambda for that.

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

    great video and thanks for sharing. I would like to upload via browser instead of postman, is there any way to api via browser ?

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

      Yes, you would need to build a front end ui...like a react ui web page that can make calls to the api similar to postman.

    • @PreetkanwalSingh
      @PreetkanwalSingh 4 หลายเดือนก่อน

      @@letsfindsolutions can you tell how to do that in Vue.js
      , i tried a lot, didnt get any solution

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

    i want to do OTA update by giving this the url of the uploaded firmware file. is this method ok for that? what happened if I just upload the binary file?

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

      This methid requires a valid jwt token...so as long as you can authenticate and pass along a token this will work.

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

    good one, thank you

  • @NikhilGupta-r6n
    @NikhilGupta-r6n ปีที่แล้ว

    Thanks it works for me, now problem i am facing is, once file upload to s3 bucket i can see file, but when i use to open that file with object url than my file is not opening, its giving me error like access denied so let me know how to give public writes to view that file simultaneously.

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

      I believe you will need to update the permissions of the s3 bucket to allow for public read.

    • @NikhilGupta-r6n
      @NikhilGupta-r6n ปีที่แล้ว

      @@letsfindsolutions Thanks i done yesterday only by myself by creating policy

  • @proan_1992
    @proan_1992 5 หลายเดือนก่อน

    was there a change in AWS UI, I am having a problem creating api resource as path parameter using {}?

    • @letsfindsolutions
      @letsfindsolutions  5 หลายเดือนก่อน

      Yes they changed the ui a while back

    • @venkat-0412
      @venkat-0412 2 หลายเดือนก่อน

      @@letsfindsolutions so can we proceed without giving {bucket}, kindly confirm will it work

    • @letsfindsolutions
      @letsfindsolutions  2 หลายเดือนก่อน

      @@venkat-0412 I have not tried it.

  • @VanshikaSharma-m7u
    @VanshikaSharma-m7u 7 หลายเดือนก่อน

    It is uploading the file into but there are some issues m facing:
    1) even if am specifying the content type in Binary-media-type (audio/mp3), still m able to upload any file
    2) the file gets corrupted when it's uploaded
    I tried form postman and even tried using flutter

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

      Possibly the encoding is messing up somehow...aside from that i. Not really sure what else it could be.

  • @anthonysosa1900
    @anthonysosa1900 6 หลายเดือนก่อน +1

    genioooooo!!!, gracias loco

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

    what are configuration for your stage of dev?
    And my problem is that file successfully upload but size is 0kb so any solution?

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

      What are you using to test the upload? In the video I use postman and i believe all its doing is converting the data to base64 encoded binary data. Similar to what a web browser would do.

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

      Thanks
      @@letsfindsolutions

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

    How would it be via POST, to send file via base64 string?

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

      I think you can change the method to a POST and just add in additional media types to handle the base64 encoded data being passed.

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

    How can I get the content of the file in the bucket using the api?
    I mean GET method

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

      You would need to write a new get method to read and serve back the content.

  • @P.Shivakrishna
    @P.Shivakrishna ปีที่แล้ว +1

    While Edit integration request to add URL path parameters when click save it showing Network Failure( Anyone help Currently I am Using ap-south-1 Region ) i don't know what is the problem ??

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

      Not sure im understanding the iasue...but maybe try switching regions. I usually use us east.

    • @P.Shivakrishna
      @P.Shivakrishna ปีที่แล้ว

      @@letsfindsolutions I tried us east also but it's not working in api gateway

    • @gurpreetkaur-cw8wo
      @gurpreetkaur-cw8wo 6 หลายเดือนก่อน

      i am also facing same problem while creating resource in API gateway can't add brackets with bucket in resource path, same with filename , my resource path is not taking brackets or I can say anything . error invalid mapping expression parameter specified

    • @gurpreetkaur-cw8wo
      @gurpreetkaur-cw8wo 6 หลายเดือนก่อน

      I resolve my problem put path in single inverted comma '' that will work as i am not getting option to put curly brackets

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

    I followed the steps precisely, but I am encountering the following error: "message": "Missing Authentication Token". I have verified the steps multiple times. May I know what could be the reason for this error?

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

      Are you passing the token in the Authorization header?

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

      @@letsfindsolutions No, I have not.

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

      The token needs to be passed in the Auth header

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

    i am getting internal server error while calling the api.
    is it something to do with WAF or ListWebACLs?

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

      Internal server error leads me to believe maybe code related...did you modify the sample code?

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

      @@letsfindsolutions there's no code..i followed your steps.. m getting a WCL error on the screen tho,,,could it be the issue? or it seems like s3 access isue

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

      Ya could be s3 permission issue

  • @TPDene
    @TPDene 5 หลายเดือนก่อน

    I don't have the "Create policy" button from 2:37 .. any ideas why?

    • @letsfindsolutions
      @letsfindsolutions  5 หลายเดือนก่อน

      They changed the ui a while back...it might look different now.

    • @venkat-0412
      @venkat-0412 2 หลายเดือนก่อน

      you can just go to policy and create it instead of trying to do it from roles

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

    It should return the link for access the file

  • @TheRealKosalaHandlersMail
    @TheRealKosalaHandlersMail 4 หลายเดือนก่อน

    Does anyone know how to do the same with Terraform?

    • @letsfindsolutions
      @letsfindsolutions  4 หลายเดือนก่อน

      I sure there are some yaml samples out there. Unfortunately I don't have any.

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

    In this method, can anybody in the world upload to my bucket? What if i wanted to restrict it to just myself? Using an access token or api key?

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

      With api gateway you can enable an Authorizer and have it validate a token i the header. You can setup cognito to work with the authorizer to validate the tokens.

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

      Look at my other video about jwt authorizer....you would use the same approach there.

  • @damarisscott7643
    @damarisscott7643 6 หลายเดือนก่อน

    Hi all, I'm pretty new. I followed all these steps, made sure that my S3 and API endpoint are in the same region and yet, I still keep getting this error: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint
    I'm trying to upload a JSON file. Have any of you had this issue?

    • @letsfindsolutions
      @letsfindsolutions  6 หลายเดือนก่อน

      I have never encountered this issue. In readibg your error, this looks to be endpoint uri related or something wrong with the endpoint permissions.

    • @damarisscott7643
      @damarisscott7643 5 หลายเดือนก่อน

      @@letsfindsolutions Hi, it was something with the permissions :) Thanks for your reply, I was able to resolve it

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

      Np

  • @sachinbaghel6225
    @sachinbaghel6225 9 หลายเดือนก่อน

    When I give a path resource, it does not get it

    • @letsfindsolutions
      @letsfindsolutions  9 หลายเดือนก่อน

      Maybe try recreating it. Sometimes that helps.

    • @sachinbaghel6225
      @sachinbaghel6225 9 หลายเดือนก่อน +1

      @@letsfindsolutions by the way thak its help

    • @gurpreetkaur-cw8wo
      @gurpreetkaur-cw8wo 6 หลายเดือนก่อน

      i am also facing same problem while creating resource in API gateway can't add brackets with bucket in resource path, same with filename , my resource path is not taking brackets or I can say anything . error invalid mapping expression parameter specified
      can you help me

    • @sachinbaghel6225
      @sachinbaghel6225 6 หลายเดือนก่อน

      @@gurpreetkaur-cw8woWhen creating a resource, simply write the name within {} brackets, and it will work.

  • @ManishKumar-rz9ub
    @ManishKumar-rz9ub 4 หลายเดือนก่อน

    i am getting "Internal server error"

    • @letsfindsolutions
      @letsfindsolutions  4 หลายเดือนก่อน

      I know the ui looks different, but my guess is that this is most likely configuration related

  • @jihad-m8y
    @jihad-m8y ปีที่แล้ว

    no it did not work time wasted

  • @RajeshKumar-b1i
    @RajeshKumar-b1i 2 หลายเดือนก่อน

    I do same thing. but when i fill url parameter that not accept it gives me error.
    I seen many videos but i cant find that soloution .
    and also aws foramte changed.
    error is ---Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression parameter specified: method.request.path.bucket]

    • @letsfindsolutions
      @letsfindsolutions  2 หลายเดือนก่อน

      Unfortunately you are right about aws ui changes. Without seeing the issue it's hard for me to guide you.