Note
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.
file¶
boto.file.bucket¶
-
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.
Parameters: - 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
Parameters: - 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: Returns: 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
-
boto.file.simpleresultset¶
-
class
boto.file.simpleresultset.
SimpleResultSet
(input_list)¶ ResultSet facade built from a simple list, rather than via XML parsing.
boto.file.connection¶
boto.file.key¶
-
class
boto.file.key.
Key
(bucket, name, fp=None, key_type=0)¶ -
KEY_REGULAR_FILE
= 0¶
-
KEY_STREAM
= 3¶
-
KEY_STREAM_READABLE
= 1¶
-
KEY_STREAM_WRITABLE
= 2¶
-
close
()¶ 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.
Parameters: Return type: string
Returns: 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’.
Parameters:
-
get_file
(fp, headers=None, cb=None, num_cb=10, torrent=False)¶ Retrieves a file from a Key
Parameters: - fp (file) – File pointer to put the data into
- cb (int) – ignored in this subclass.
- num_cb – ignored in this subclass.
Param: ignored in this subclass.
-
is_stream
()¶
-
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.
Parameters: - 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.
-