python3 boto3 put and put object to s3

Solutions on MaxInterview for python3 boto3 put and put object to s3 by the best coders in the world

showing results for - "python3 boto3 put and put object to s3"
Lennart
11 Feb 2018
1import boto3
2
3some_binary_data = b'Here we have some data'
4more_binary_data = b'Here we have some more data'
5
6# Method 1: Object.put()
7s3 = boto3.resource('s3')
8object = s3.Object('my_bucket_name', 'my/key/including/filename.txt')
9object.put(Body=some_binary_data)
10
11# Method 2: Client.put_object()
12client = boto3.client('s3')
13client.put_object(Body=more_binary_data, Bucket='my_bucket_name', Key='my/key/including/anotherfilename.txt')
14