by

Amazon S3 Aws - Adding a file to a bucket using boto API

This python example shows how to add some content to an existing bucket to Amazon S3.   
You need to add a new key, named as the filename and then invoke the set\_contents\_from\_string method to add a new file.

Prerequisites:    
You need an existing bucket.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/4893/Amazon-S3-Aws---Adding-a-file-to-a-bucke?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
# This creates a file hello.txt with the string "Hello World!" key = bucket.new_key('hello.txt') key.set_contents_from_string('Hello World!')

Other Steps and Solutions

If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus