How to Upload files from local to AWS S3 using Python (Boto3) API | upload_file method |Handson Demo

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello in this video i am going to show you how to upload a file from your local desktop into amazon s3 bucket using python so to do this we will be using the bottom 3 module which is an aws sdk for python given by aws so from the photo 3 we will create an s3 client and we will use this upload file method to upload this file from your local desktop to the sd bucket so firstly if you don't know what boot 3 is boto3 is just an aws sdk for python basically if you want to interact with aws services using python you can use this portal 3 module so they have aws has a very good documentation of quota 3 module we can refer to this site so i have opened the voter 3 documentation for s3 so we will click on client here and if you see here these are the various methods available uh for you know to interact with aws services there is a create bucket copy object delete bucket there are a lot of features i mean lot of methods available so for us to upload the file we need to have a method called upload file here so let's look for that uh method so this is the method we will use uh upload file method to upload a file from our desktop to the aws s3 bucket so if you see here this also shows a sample usage of how to uh use this i mean method okay so now let's take this sample usage method uh sample use sample code and copy it in our pie chart so to run this code from your pie chart you need to have a setup done so if you don't know how to do the setup i have already explained that in my other video i'm going to place a link for that video in this description please check out that video if you have not done it already so once you have the setup done so it's very simple so you are importing the moto 3 module and then you are just creating uh s3 resource and then you are using this upload file method to upload the data from your local to the s3 bucket so basically the arguments if you see here the first tag first parameter is the file name which you want to upload and the basically the path to that file and the second one is the bucket to which you want to upload and the third one is the basically the name of the file in the destination basically so this is the bucket which i want to upload uh my data to and now let me go here and so this is the file that we will be uploading basically this sachin.jpg file so we need to copy this path and you know paste it over here so let me um quickly take that path the path and then so basically this is the parameter which is uh is true is the path so so since this is a file path let me just give r here so that it will be able to read it and the second parameter is your bucket name so this is my bucket name okay and i'll give this and this is the name of the file uh in the destination what you want to give basically you can give any name that you want uh let me give it section one two three dot jpg so this file will be saved as sachin123.jpg in this bucket okay so if you want to load it to any particular directory you can call like you know my images and slash so basically it will be loaded into this directory in this history bucket okay so um let's run this code and let's see if the file gets uploaded here okay so basically what i'm expecting is after the code is there should be a directory called my image is created and inside that the file should be uploaded so let me quickly run this code so if you see the process exited finish with exit code so let me check the aws console here so if you see there is a my images folder created and there is a sachin 123.jpg uploaded to this file so it's very simple this is how you you know make use of the aws 423 module to do anything that you want basically so you can i mean always refer to this photo three documentation to see uh which method you know is very so i mean suits your requirement and you know you can go through the documentation to see what are the parameters that distribute and make use of this documentation thank you and i'll see you in the next video do not forget to subscribe to my channel
Info
Channel: AWS Made Easy
Views: 14,007
Rating: undefined out of 5
Keywords: AWS, Cloud, Python, Boto3, AWS-API
Id: s9PVPijAw3I
Channel Id: undefined
Length: 4min 21sec (261 seconds)
Published: Sat Mar 19 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.