How to download files from AWS S3 with FastAPI ?

  Рет қаралды 4,049

Jr. Developer

Jr. Developer

Күн бұрын

#fastapi #python #aws #awss3 #s3 #webdevelopment
Hello everyone
This video gives a demo on how you can download a file from AWS S3 using FastAPI.
Happy coding!!
Links:
AWS CLI: docs.aws.amazo...
boto3 credentials: boto3.amazonaw...

Пікірлер: 19
@jr.developer
@jr.developer Жыл бұрын
Source code: github.com/jrdeveloper124/file-transfer/blob/main/main.py
@pkleiz
@pkleiz Жыл бұрын
Nice indian guy
@gopikrishna3481
@gopikrishna3481 6 ай бұрын
​​@jr.developer I have tried for a larger zip file with streaming response, once the file is available to download then chrome is crashing and unable to view swagger.. So I'm unable to download the file.. So instead of that can we directly download into the downloads folder whenever api is called?
@jr.developer
@jr.developer 6 ай бұрын
Swagger might be overwhelmed by the large file size. It's just for us to understand and document our APIs easily. You can put the endpoint in the browser and that should start the download process. For the browser to show the download progress - try adding the Content-Length header in the response. Hope that helps. Thank you for your comment.
@hackwithharsha
@hackwithharsha Жыл бұрын
Hey, Thank You !! What is the python version that you are using, instead of Union you seem to be using pipe symbol..
@jr.developer
@jr.developer Жыл бұрын
I'm using Python 3.10 which supports this symbol( | ). You can still use Union if you want to 🙂
@hackwithharsha
@hackwithharsha Жыл бұрын
@@jr.developer Okiee. Thank You !!
@khyatisonkar
@khyatisonkar Жыл бұрын
hi, how can we download all files present inside the amazon s3 bucket?
@jr.developer
@jr.developer Жыл бұрын
Great question! I have never run into a situation where I needed to download all files from s3(which might take a significant amount of time based on the number of files in your bucket). I found a few interesting solutions on stackoverflow: stackoverflow.com/questions/31918960/boto3-to-download-all-files-from-a-s3-bucket. Hope that helps...
@gopikrishna3481
@gopikrishna3481 6 ай бұрын
Does the download api work for larger files with size greater than 2GB
@jr.developer
@jr.developer 6 ай бұрын
It would be limited by the available disk space. I would definately not consider this for large files. For large files, we can consider streaming. I haven't tried it myself yet but I found a FastAPI + boto example - stackoverflow.com/questions/69617252/response-file-stream-from-s3-fastapi
@gopikrishna3481
@gopikrishna3481 6 ай бұрын
​@@jr.developerI have tried for a larger zip file with streaming response, once the file is available to download then chrome is crashing and unable to view swagger.. So I'm unable to download the file.. So instead of that can we directly download into the downloads folder whenever api is called?
@jr.developer
@jr.developer Ай бұрын
Swagger is not the way to interact with your API. It's just for documentation purposes and quickly becomes unresponsive even for a large JSON response. Please, consider opening the API endpoint in a browser directly and the browser should let you choose a location on your computer.
@artemshumeiko
@artemshumeiko Жыл бұрын
Thanks a lot! Do you have same code version with aioboto3 implemented instead boto3?
@jr.developer
@jr.developer Жыл бұрын
Sorry, but I haven't tried that yet. It should be similar to boto3 though.
@nikilkvn
@nikilkvn Жыл бұрын
Thanks so much for the content.,. But I was getting "Object of type bytes is not JSON serializable" tried the exact same code.. am able to print the contents in bytes.. but the response is failing somehow..
@nikilkvn
@nikilkvn Жыл бұрын
my mistake.. I was using JsonResponse instead the regular Response. Thanks a lot for the video.
@azabelletale5013
@azabelletale5013 Жыл бұрын
Thank you for the great video. It saved me. Would you please do a video for how to do it with authorization (jwt) as well?
@jr.developer
@jr.developer Жыл бұрын
Will do... Thanks for the idea 👍🏻
How to paginate with FastAPI
21:02
Jr. Developer
Рет қаралды 5 М.
How to upload files to AWS S3 with FastAPI ?
13:06
Jr. Developer
Рет қаралды 9 М.
How Strong is Tin Foil? 💪
00:26
Preston
Рет қаралды 130 МЛН
Офицер, я всё объясню
01:00
История одного вокалиста
Рет қаралды 4,1 МЛН
Download Files from AWS S3 using Python
39:18
I am Lu
Рет қаралды 4,3 М.
Uploading Files to AWS S3 using Python and Boto3
17:49
Financial Python
Рет қаралды 1,8 М.
Upload Images Directly to S3 from Front End
18:28
Sam Meech-Ward
Рет қаралды 124 М.
Quickly Authenticate Users with FastAPI and Token Authentication
46:05
Akamai Developer
Рет қаралды 111 М.
Upload and Download files from AWS S3 Bucket using python 2022
10:59
How to Return Files in FastAPI
10:40
Pretty Printed
Рет қаралды 28 М.
Every FastAPI File Upload Method | Working and Best Practices!
6:22
Code Collider
Рет қаралды 3,7 М.
build your own cloud
47:13
NetworkChuck
Рет қаралды 1,9 МЛН
How Strong is Tin Foil? 💪
00:26
Preston
Рет қаралды 130 МЛН