Adding and Getting Files from Amazon S3 with Serverless.

  Рет қаралды 14,812

Complete Coding - Master AWS Serverless

Complete Coding - Master AWS Serverless

Күн бұрын

In this video we'll be creating two new API endpoints. One to add JSON data to our Amazon S3 bucket, and one to get files back.
By the end of this video you will have:
- Added two more endpoints to your serverless application
- Created a wrapper to easily read and write files from Amazon S3
- Uploaded JSON data to your S3 bucket via an endpoint
- Downloaded JSON data from your S3 bucket
Complete code for this file is available here:
github.com/SamWSoftware/Serve...

Пікірлер: 45
@shwenansuwai2481
@shwenansuwai2481 4 жыл бұрын
Thank you very much, Sam. Enjoyed this tutorial.
@CompleteCoding
@CompleteCoding 4 жыл бұрын
Glad you enjoyed it
@AmruAshik
@AmruAshik 3 жыл бұрын
crisp and clear explanation!! cheers !!
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Glad you think so!
@MohammedNoureldin
@MohammedNoureldin 3 жыл бұрын
That was awesome dude! Thanks a lot! 1000 thumbs up!
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Glad you liked it and thanks for the support!
@abbisalmi1948
@abbisalmi1948 3 жыл бұрын
Thanks for the great video. It’s really helpful and the closest I found to production work. However note that Lambda doesn’t have a big payload so large files will require different approaches (e.g. signed Urls)
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Yes, if you're transferring large files then yes, you'd need to use signed urls or another approach.
@Mos-pt8lz
@Mos-pt8lz Жыл бұрын
I really enjoy all your videos because it direct to the point, one thing i missing here is different types of encryption of uploaded file, would be great if you make a video to explain how this could be implemented in the code
@CompleteCoding
@CompleteCoding Жыл бұрын
You can configure your S3 bucket so all files are encrypted automatically at upload. Makes this super simple for storing encrypted files. No real coding required. You could encrypt it before you upload it (in the web app) and then the user can decrypt it again when they download it. that would all be frontend work ( encrypting and decrypting in react ) Another option is to encrypt it manually in the Lambda before storing it in S3. I don't really see the point in this vs option 1. If you did go for option 2 or 3 then you'd just use a library to do the encryption. This isn't something I've ever done so can't really recommend any packages.
@1407link
@1407link 2 жыл бұрын
Thanks chamo, you are the best!!
@CompleteCoding
@CompleteCoding 2 жыл бұрын
Thank you!
@shadmanmartinpiyal4057
@shadmanmartinpiyal4057 3 жыл бұрын
Excellent video. I am also gonna watch that video on image uploading to s3.
@CompleteCoding
@CompleteCoding 3 жыл бұрын
I hope that you enjoy it
@durgatce
@durgatce Жыл бұрын
Thanks a lot for sharing this info. Can you also let us know how we can set the expiration lifecycle for the S3 through serverless.
@mayankchotaliya5704
@mayankchotaliya5704 2 жыл бұрын
Great Video Sam! Just a quick question if we want to upload a CSV file in the bucket and perform operations on it on the client side will this code work?
@CompleteCoding
@CompleteCoding Жыл бұрын
Yes, writing and reading csv files should work just the same. You'll have to convert it from cvs to JSON to be able to process it in the front end
@user-ci8vx2tu7j
@user-ci8vx2tu7j Жыл бұрын
I'm getting error when i'm trying to see my files in lambda. Does any one having clue ? You cannot open any files within this directory through the UI. This file can be opened via the command line. This issue only affects files with the file path /home/ec2-user/environment/home/ec2-user/environment. Check documentation
@sorrynthxkim4637
@sorrynthxkim4637 Жыл бұрын
when I run "sls deploy" again, car.json file in S3 is deleted. Any idea to prevent auto delete ?
@LeighPenn
@LeighPenn 4 жыл бұрын
Great tutorial! Is it possible to create these uploading and downloading functions but deployed as its own s3 static website? To expand, a s3 website interface that is able to get files and upload files listed on the s3 console
@CompleteCoding
@CompleteCoding 4 жыл бұрын
Yes definitely. I'm planning to do some videos where I build simple from end websites that interact with the APIs built in this course.
@josejaimes4965
@josejaimes4965 4 жыл бұрын
I really enjoy this tutorials, Sam. Thanks for create them. I was wondering how to associate a file to one register into another table (for example player-points table). Would it be as easy as create an additional field called "Certificate" and save it here? BUT how could I trigger this process update routine of player to achieve it? or this is a frontend process and it is not neccesary to do it like this? I really appreciate your commnets about it.
@CompleteCoding
@CompleteCoding 4 жыл бұрын
Do you mean allowing the user to upload a file which you save in S3 and then add a field in dynamo which is the url of the uploaded object? If you do then you can definitely do that. You could modify the update player endpoint to also take an optional 'file' in the body of the request (similar to this video). If that parameter is present then you write the file to S3 as you do in this video. When you get back the details and calculate the URL you would add that as a parameter in the dynamo write data. This way when you next get that player score, there will be a URL in the data, pointing to that S3 file.
@josejaimes4965
@josejaimes4965 4 жыл бұрын
@@CompleteCoding Thanks for the comments. Could I upload a .zip file using this same Bucket?
@muzammalabdulghafoor6418
@muzammalabdulghafoor6418 3 жыл бұрын
Hi Sam! The way you are explaining is excellent. I just want to ask you a question, I have a scenario where I need to upload multiple images to the s3 bucket using api gateway which I will consume in android app. Could you please make a video on it or refer me any blog or anything else thorough which I could solve my problem. please reply 🙏🙏🙏🙏🙏
@CompleteCoding
@CompleteCoding 3 жыл бұрын
I have a video on image upload already The API part kzfaq.info/get/bejne/faieaN2axK7MoZ8.html The react app: kzfaq.info/get/bejne/bK2glLGAvty-c3k.html Once the image is in S3, if you've made it public then you can just show that in the app. If it is private then you would have to use a signed url
@KristianCevallos
@KristianCevallos 4 жыл бұрын
Hello thank you very much for the tutorial, can you help me with a recommendation to download files from an S3 to an EC2, I am trying with lambda and an api rest
@CompleteCoding
@CompleteCoding 4 жыл бұрын
You have two main options. You could either call your S3 get API from your server. If you've already followed this video then you should have an API which you can hit from your server. The other option is to add the logic for getting from S3 to your server directly. You will also need to give your EC2 permission to read from S3 but it saves the extra work of building and deploying your API. Hope that helps
@KristianCevallos
@KristianCevallos 4 жыл бұрын
@@CompleteCoding Thank you very much it is quite helpful, the file is deposited in the S3 on user request as I do it automatically an event of the S3 can invoke a rest service or implement the api
@FelipeFett
@FelipeFett 4 жыл бұрын
There's a better approach using regex to check the file type on 17:20 /\.json$/.test(fileName)
@CompleteCoding
@CompleteCoding 4 жыл бұрын
That's a good point. I'll put that option into the text version of this video
@masudrana1983
@masudrana1983 Жыл бұрын
I am getting error when run this command: sls deploy Cannot read file node_modules\yamljs\cli\yaml2json.js due to: EMFILE: too many open files, open 'C:\Users\Masud\projects\learning\serverless-test ode_modules\yamljs\cli\yaml2json.js'
@CompleteCoding
@CompleteCoding Жыл бұрын
I've never seen that error before. There seem to be some answers if you google the error message
@vinodsamy1725
@vinodsamy1725 3 жыл бұрын
Is that possible from single endpoint Adding and Getting Files from Amazon S3??
@CompleteCoding
@CompleteCoding 3 жыл бұрын
Yes, if you wanted to you could add both functionality into a single endpoint. One example I could think where you might is if you were creating a API to "find similar something". If it was for movies, you would post up the data for the movie, do some logic to find similar movies and then get those movies to return to the user.
@vinodsamy1725
@vinodsamy1725 3 жыл бұрын
@@CompleteCoding Thank you:)
@fg0611
@fg0611 2 жыл бұрын
hi, why we need webpack installed?
@CompleteCoding
@CompleteCoding 2 жыл бұрын
Webpack takes all of the code required for the function and puts it into a single file. If you don't then ask code in the repo ends up in every lambda. With lots of endpoints the lambda can become too big to deploy
@fg0611
@fg0611 2 жыл бұрын
@@CompleteCoding Thank you for clearing that!
@illbet4589
@illbet4589 3 жыл бұрын
so this only work with JSON ?... and not uploading actual files like word documents. Dang, back to google I goooo ( great vid btw)
@CompleteCoding
@CompleteCoding 3 жыл бұрын
You can store files like those in S3 but you would use another technique called "Signed Urls". That way you can use whatever file type you like - even images or videos
@zaqshaq4542
@zaqshaq4542 2 жыл бұрын
kzfaq.info/get/bejne/g9J7o65hvNe4g6c.html (...) from s3, not a dynamo great tutorial THANKS
@CompleteCoding
@CompleteCoding 2 жыл бұрын
Nice spot. I'm sure there are loads of little fumbles hidden in my videos
Securing Your Serverless API With API Keys
14:21
Complete Coding - Master AWS Serverless
Рет қаралды 10 М.
Create an API to get data from your DynamoDB Database
20:17
Complete Coding - Master AWS Serverless
Рет қаралды 22 М.
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
Пранк пошел не по плану…🥲
00:59
Саша Квашеная
Рет қаралды 7 МЛН
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
D3 LiXiang L6 Машина Года 2025?
15:14
smotraTV
Рет қаралды 217 М.
Use Presigned PUT URLs to Easily Upload Files to AWS S3
16:52
TomDoesTech
Рет қаралды 31 М.
Adding New Data to your DynamoDB Database
14:45
Complete Coding - Master AWS Serverless
Рет қаралды 10 М.
Почему 08.08.2024  - день, который нельзя пропустить | Нумеролог
21:37
Нумеролог Андрей Ткаленко
Рет қаралды 812 М.
Upload Images Directly to S3 from Front End
18:28
Sam Meech-Ward
Рет қаралды 120 М.
How to send an email with Amazon SES and Serverless - tutorial
20:02
Complete Coding - Master AWS Serverless
Рет қаралды 26 М.
I tried 8 different Postgres ORMs
9:46
Beyond Fireship
Рет қаралды 400 М.
The only Cloud services you actually need to know
17:17
NeetCodeIO
Рет қаралды 93 М.
Create a Serverless Database - DynamoDB with the Serverless Framework
9:59
Complete Coding - Master AWS Serverless
Рет қаралды 18 М.
Лучший браузер!
0:27
Honey Montana
Рет қаралды 1,1 МЛН
Bluetooth connected successfully 💯💯
0:16
Blue ice Comedy
Рет қаралды 2,2 МЛН
Какой ноутбук взять для учёбы? #msi #rtx4090 #laptop #юмор #игровой #apple #shorts
0:18
Мой новый мега монитор!🤯
1:00
Корнеич
Рет қаралды 3,8 МЛН