Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python3 boto3 put and put_object to s3

import boto3

some_binary_data = b'Here we have some data'
more_binary_data = b'Here we have some more data'

# Method 1: Object.put()
s3 = boto3.resource('s3')
object = s3.Object('my_bucket_name', 'my/key/including/filename.txt')
object.put(Body=some_binary_data)

# Method 2: Client.put_object()
client = boto3.client('s3')
client.put_object(Body=more_binary_data, Bucket='my_bucket_name', Key='my/key/including/anotherfilename.txt')
Comment

Python3 boto3 put object to s3

# Boto 2.x
from boto.s3.key import Key
key = Key('hello.txt')
key.set_contents_from_file('/tmp/hello.txt')

# Boto 3
s3.Object('mybucket', 'hello.txt').put(Body=open('/tmp/hello.txt', 'rb'))
Comment

python boto3 put_object to s3

file = open(r"/tmp/" + filename)
response = s3.meta.client.Bucket('<bucket-name>').put_object(Key='folder/{}'.format(filename), Body=file)
Comment

PREVIOUS NEXT
Code Example
Python :: python open file for reading and writing 
Python :: np.random.RandomState 
Python :: python read json file array 
Python :: subtract from dataframe column 
Python :: pyspark now 
Python :: Calculate Euclidean Distance in Python 
Python :: Python function to compute factorial of a number. 
Python :: python script to copy files to remote server 
Python :: how to label points in scatter plot in python 
Python :: python submit work to redis 
Python :: finding path of a module in python 
Python :: c++ vs python 
Python :: random 0 or 1 python 
Python :: matplotlib orange line 
Python :: difference between set and tuple in python 
Python :: join dataframe pandas by column 
Python :: Get Time from timestamp in python 
Python :: create pandas dataframe from dictionary 
Python :: how to download a .xlsx file from google colab 
Python :: read value from entry tkinter 
Python :: merge dicts python 
Python :: python tkinter arabic 
Python :: python offline translate pypi 
Python :: index a dictionary python 
Python :: with open as file python 
Python :: feature to determine image too dark opencv 
Python :: how to square root in python 
Python :: flatten tf keras 
Python :: filter dict 
Python :: python concatenate lists 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =