You are viewing the documentation for an older version of boto (boto2).

Boto3, the next version of Boto, is now stable and recommended for general use. It can be used side-by-side with Boto in the same project, so it is easy to start using Boto3 in your existing projects as well as new projects. Going forward, API updates and all new feature work will be focused on Boto3.

For more information, see the documentation for boto3.



class boto.file.bucket.Bucket(name, contained_key)

Instantiate an anonymous file-based Bucket around a single key.

delete_key(key_name, headers=None, version_id=None, mfa_token=None)

Deletes a key from the bucket.

  • key_name (string) – The key name to delete
  • version_id (string) – Unused in this subclass.
  • mfa_token (tuple or list of strings) – Unused in this subclass.
get_all_keys(headers=None, **params)

This method returns the single key around which this anonymous Bucket was instantiated.

Return type:SimpleResultSet
Returns:The result from file system listing the keys requested
get_key(key_name, headers=None, version_id=None, key_type=0)

Check to see if a particular key exists within the bucket. Returns: An instance of a Key object or None

  • key_name (string) – The name of the key to retrieve
  • version_id (string) – Unused in this subclass.
  • stream_type (integer) – Type of the Key - Regular File or input/output Stream
Return type:



A Key object from this bucket.

new_key(key_name=None, key_type=0)

Creates a new key

Parameters:key_name (string) – The name of the key to create
Return type:boto.file.key.Key
Returns:An instance of the newly created key object


class boto.file.simpleresultset.SimpleResultSet(input_list)

ResultSet facade built from a simple list, rather than via XML parsing.


class boto.file.connection.FileConnection(file_storage_uri)
get_bucket(bucket_name, validate=True, headers=None)


class boto.file.key.Key(bucket, name, fp=None, key_type=0)

Closes fp associated with underlying file. Caller should call this method when done with this class, to avoid using up OS resources (e.g., when iterating over a large number of files).

get_contents_as_string(headers=None, cb=None, num_cb=10, torrent=False)

Retrieve file data from the Key, and return contents as a string.

  • headers (dict) – ignored in this subclass.
  • cb (int) – ignored in this subclass.
  • num_cb – ignored in this subclass.
  • num_cb – ignored in this subclass.
  • torrent (bool) – ignored in this subclass.
Return type:



The contents of the file as a string

get_contents_to_file(fp, headers=None, cb=None, num_cb=None, torrent=False, version_id=None, res_download_handler=None, response_headers=None)

Copy contents from the current file to the file pointed to by ‘fp’.

  • fp (File-like object) –
  • headers (dict) – Unused in this subclass.
  • cb (int) – Unused in this subclass.
  • num_cb – Unused in this subclass.
  • torrent (bool) – Unused in this subclass.
  • res_download_handler – Unused in this subclass.
  • response_headers (dict) – Unused in this subclass.
get_file(fp, headers=None, cb=None, num_cb=10, torrent=False)

Retrieves a file from a Key

  • fp (file) – File pointer to put the data into
  • cb (int) – ignored in this subclass.
  • num_cb – ignored in this subclass.

ignored in this subclass.

set_contents_from_file(fp, headers=None, replace=True, cb=None, num_cb=10, policy=None, md5=None)

Store an object in a file using the name of the Key object as the key in file URI and the contents of the file pointed to by ‘fp’ as the contents.

  • fp (file) – the file whose contents to upload
  • headers (dict) – ignored in this subclass.
  • replace (bool) – If this parameter is False, the method will first check to see if an object exists in the bucket with the same key. If it does, it won’t overwrite it. The default value is True which will overwrite the object.
  • cb (int) – ignored in this subclass.
  • num_cb – ignored in this subclass.
  • policy (boto.s3.acl.CannedACLStrings) – ignored in this subclass.
  • md5 (A tuple containing the hexdigest version of the MD5 checksum of the file as the first element and the Base64-encoded version of the plain checksum as the second element. This is the same format returned by the compute_md5 method.) – ignored in this subclass.