by
0
8
6,245
3
Top 1% !
Popular
Famous
Pearl of Wisdom
Tagged
Easy-to-find
Specified
OpenSource
Popularity: 1081st place
Created
Modified Aug 4, 2013

Published on:

Architecturex86_64
LanguagePython
LicenseMIT_X11
Target Frameworkaws

Amazon S3 Aws - How to get content information for a given bucket using boto python api

This snippet shows how to iterate through your own Amazon S3 buckets and list the available content.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/4429/Amazon-S3-Aws---How-to-get-content-infor?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
import boto import boto.s3.connection access_key = '<aws access key>' secret_key = '<aws secret key>' # This code initialize the Amazon S3 connection to your account conn = boto.connect_s3( aws_access_key_id = access_key, aws_secret_access_key = secret_key) # Iteration through all available buckets stored into S3 # Name and creation date are listed for bucket in conn.get_all_buckets(): print "{name}\t{created}".format( name = bucket.name, created = bucket.creation_date, ) # For each bucket get all data content put into the bucket for key in bucket.list(): # Get name, size and date print "{name}\t{size}\t{modified}".format( name = key.name, size = key.size, modified = key.last_modified, )

Other Steps and Solutions

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

blog comments powered by Disqus