Explore Public Snippets
Found 23 snippets matching: "aws python"
public by fabio.nosenzo @ Amazon_AWS_Python_API 588169 5 8 -1
Amazon S3 Aws - S3Connection object from python boto API
import boto.utils from boto.connection import AWSAuthConnection class S3Connection(AWSAuthConnection): DefaultHost = boto.config.get('s3', 'host', 's3.amazonaws.com') DefaultCallingFormat = boto.config.get('s3', 'calling_format', 'boto.s3.connection.SubdomainCallingFormat') QueryString = 'Signature=%s&Expires=%d&AWSAccessKeyId=%s' def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, is_secure=True, port=None, proxy=None, proxy_port=None, proxy_user=None, proxy_pass=None, host=DefaultHost, debug=0, https_connection_factory=None, calling_format=DefaultCallingFormat, path='/', provider='aws', bucket_class=Bucket, security_token=None, suppress_consec_slashes=True, anon=False, validate_certs=None): if isinstance(calling_format, str): calling_format=boto.utils.find_class(calling_format)() self.calling_format = calling_format self.bucket_class = bucket_class self.anon = anon AWSAuthConnection.__init__(self, host, aws_access_key_id, aws_secret_access_key, is_secure, port, proxy, proxy_port, proxy_user, proxy_pass, debug=debug, https_connection_factory=https_connection_factory, path=path, provider=provider, security_token=security_token, suppress_consec_slashes=suppress_consec_slashes, validate_certs=validate_certs)
public by lbottaro @ Amazon_AWS_Python_API 304436 0 8 0
Amazon S3 Aws - How to download a file from a bucket to a target directory
# This downloads the object foobar.pdf and saves it in /home/luca/documents/ key = bucket.get_key('foobar.pdf') key.get_contents_to_filename('/home/luca/documents/foobar.pdf')
public by lbottaro @ Amazon_AWS_Python_API 10729 32 8 0
Amazon S3 Aws - Change an object's acl using boto API
# Public ACL example # Here you get the key reference for file foo_bar.txt foo_bar_key = bucket.get_key('foo_bar.txt') # This set the foo_bar file publicly readable foo_bar_key.set_canned_acl('public-read') # Private ACL example # Here you get the key reference for file secret.txt secret_key = bucket.get_key('secret.txt') # This set the secret.txt file as private secret_key.set_canned_acl('private')
public by lbottaro @ Amazon_AWS_Python_API 6434 19 8 1
Amazon S3 Aws - How to delete a bucket using boto API
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, ) # Remove the bucket conn.delete_bucket(bucket.name)
public by lbottaro @ Amazon_AWS_Python_API 6271 3 8 0
Amazon S3 Aws - How to get content information for a given bucket using boto python api
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, )
public by lbottaro @ Amazon_AWS_Python_API 6138 1 8 1
Amazon S3 Aws - get_bucket method in boto python API
from boto.s3.connection import S3Connection from boto.s3.key import Key # Get connection using Amazon secret and access keys conn = S3Connection('<aws secret key>', '<aws access key>') # Get the bucket with name 'bucketname' bucket = conn.get_bucket('bucketname') # Get the key reference to file 'picture.jpg' key = bucket.get_key("picture.jpg") # Open file in write mode fp = open ("picture.jpg", "w") # Set the reference to file key.get_file (fp)
public by lbottaro @ Amazon_AWS_Python_API 5979 1 8 1
Amazon S3 Aws - Generate signed object download URLs
# Get the private key reference to secret_plans.txt file plans_key = bucket.get_key('secret_plans.txt') # Generate a signed URL, timer is set to 1 hour plans_url = plans_key.generate_url(3600, query_auth=True, force_http=True) print plans_url
public by lbottaro @ Amazon_AWS_Python_API 5468 5 8 1
Amazon S3 Aws - Generate unsigned object download URLs
# Create an unsigned download URL for hello.txt. # Requirements: # file hello.txt is public by setting its ACL # Get hello.txt file key from bucket hello_key = bucket.get_key('hello.txt') # Create the unsigned URL hello_url = hello_key.generate_url(0, query_auth=False, force_http=True) print hello_url
public by lbottaro @ Amazon_AWS_Python_API 5094 1 8 0
How To Create A Connection To Amazon S3 Aws with Boto using connect_s3 method
import boto conn = boto.connect_s3() # connect_s3() will return the S3Connection object. # conn will point to your S3Connection object, ready to interact with your AWS account
public by lbottaro @ Amazon_AWS_Python_API 4594 1 8 2
Amazon S3 Aws - Creating a bucket in python
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) # This creates a new bucket called myBucket bucket = conn.create_bucket('myBucket')