pyrax
Python Bindings for the Rackspace Cloud
|
This class represents an object stored in a Container. More...
Public Member Functions | |
def | __init__ |
def | __repr__ |
def | id |
StorageObjects use their 'name' attribute as their ID. | |
def | total_bytes |
Alias for backwards compatibility. | |
def | etag |
Alias for backwards compatibility. | |
def | container |
def | get |
Fetches the object from storage. | |
def | download |
Fetches the object from storage, and writes it to the specified directory. | |
def | copy |
Copies this object to the new container, optionally giving it a new name. | |
def | move |
Works just like copy_object, except that this object is deleted after a successful copy. | |
def | change_content_type |
Copies object to itself, but applies a new content-type. | |
def | purge |
Removes a CDN-enabled object from public access before the TTL expires. | |
def | get_metadata |
Returns the metadata for this object as a dict. | |
def | set_metadata |
Accepts a dictionary of metadata key/value pairs and updates the specified object metadata with them. | |
def | remove_metadata_key |
Removes the specified key from the storage object's metadata. | |
def | get_temp_url |
Returns a URL that can be used to access this object. | |
def | delete_in_seconds |
Sets the object to be deleted after the specified number of seconds. | |
Static Public Attributes | |
fetch = get |
This class represents an object stored in a Container.
def __init__ | ( | self, | |
manager, | |||
info, | |||
args, | |||
kwargs | |||
) |
Reimplemented from BaseResource.
def __repr__ | ( | self | ) |
Reimplemented from BaseResource.
def change_content_type | ( | self, | |
new_ctype, | |||
guess = False |
|||
) |
Copies object to itself, but applies a new content-type.
The guess feature requires the container to be CDN-enabled. If not then the content-type must be supplied. If using guess with a CDN-enabled container, new_ctype can be set to None. Failure during the put will result in a swift exception.
def container | ( | self | ) |
def copy | ( | self, | |
new_container, | |||
new_obj_name = None , |
|||
extra_info = None |
|||
) |
Copies this object to the new container, optionally giving it a new name.
If you copy to the same container, you must supply a different name.
def delete_in_seconds | ( | self, | |
seconds | |||
) |
Sets the object to be deleted after the specified number of seconds.
def download | ( | self, | |
directory, | |||
structure = True |
|||
) |
Fetches the object from storage, and writes it to the specified directory.
The directory must exist before calling this method.
If the object name represents a nested folder structure, such as "foo/bar/baz.txt", that folder structure will be created in the target directory by default. If you do not want the nested folders to be created, pass `structure=False` in the parameters.
def etag | ( | self | ) |
Alias for backwards compatibility.
def get | ( | self, | |
include_meta = False , |
|||
chunk_size = None |
|||
) |
Fetches the object from storage.
If 'include_meta' is False, only the bytes representing the file is returned.
Note: if 'chunk_size' is defined, you must fully read the object's contents before making another request.
When 'include_meta' is True, what is returned from this method is a 2-tuple: Element 0: a dictionary containing metadata about the file. Element 1: a stream of bytes representing the object's contents.
def get_metadata | ( | self | ) |
Returns the metadata for this object as a dict.
def get_temp_url | ( | self, | |
seconds, | |||
method = "GET" |
|||
) |
Returns a URL that can be used to access this object.
The URL will expire after `seconds` seconds.
The only methods supported are GET and PUT. Anything else will raise an InvalidTemporaryURLMethod exception.
def id | ( | self | ) |
StorageObjects use their 'name' attribute as their ID.
def move | ( | self, | |
new_container, | |||
new_obj_name = None , |
|||
extra_info = None |
|||
) |
Works just like copy_object, except that this object is deleted after a successful copy.
This means that this storage_object reference will no longer be valid.
def purge | ( | self, | |
email_addresses = None |
|||
) |
Removes a CDN-enabled object from public access before the TTL expires.
Please note that there is a limit (at this time) of 25 such requests; if you need to purge more than that, you must contact support.
If one or more email_addresses are included, an email confirming the purge is sent to each address.
def remove_metadata_key | ( | self, | |
key, | |||
prefix = None |
|||
) |
Removes the specified key from the storage object's metadata.
If the key does not exist in the metadata, nothing is done.
def set_metadata | ( | self, | |
metadata, | |||
clear = False , |
|||
prefix = None |
|||
) |
Accepts a dictionary of metadata key/value pairs and updates the specified object metadata with them.
If 'clear' is True, any existing metadata is deleted and only the passed metadata is retained. Otherwise, the values passed here update the object's metadata.
By default, the standard object metadata prefix ('X-Object-Meta-') is prepended to the header name if it isn't present. For non-standard headers, you must include a non-None prefix, such as an empty string.
def total_bytes | ( | self | ) |
Alias for backwards compatibility.