boto3 upload file to s3

import boto3
s3 = boto3.resource('s3')
s3.meta.client.upload_file('https://cdn.myedukit.com/tmp/hello.txt', 'mybucket', 'hello.txt')

Here is what the above code is Doing:
1. Creating a resource service client using boto3.
2. Calling the upload_file method. This method requires a file name, a bucket name, and an object name.
3. Specifying the full path of the file to upload, as well as the bucket and object names.

The upload_file method will create an object in the bucket if one doesn’t already exist.

If you run the code above, you should see the following output:

Uploaded hello.txt to mybucket/hello.txt

You can also verify that the file was uploaded by going to the S3 console and viewing the contents of your bucket.

Downloading a File

To download a file from an S3 bucket, you’ll need to use the Boto3 download_file method.

Here’s the code you’ll need to write in order to download a file from an S3 bucket:

import boto3
s3 = boto3.resource(‘s3’)
s3.meta.client.download_file(‘mybucket’, ‘hello.txt’, ‘/tmp/hello.txt’)