pyrax
Python Bindings for the Rackspace Cloud
|
Represents a CloudFiles storage object. More...
Public Member Functions | |
def | __init__ |
The object can either be initialized with individual params, or by passing the dict that is returned by swiftclient. | |
def | get |
Fetches the object from storage. | |
def | download |
Fetches the object from storage, and writes it to the specified directory. | |
def | delete |
Deletes the object from storage. | |
def | purge |
Purges the object from the CDN network, sending an optional email confirmation. | |
def | get_metadata |
Returns this object's metadata. | |
def | set_metadata |
Sets this object's metadata, optionally clearing existing metadata. | |
def | remove_metadata_key |
Removes the specified key from the storage object's metadata. | |
def | change_content_type |
Copies object to itself, but applies a new content-type. | |
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. | |
def | __repr__ |
Public Attributes | |
client | |
container | |
name | |
total_bytes | |
content_type | |
last_modified | |
etag | |
Static Public Attributes | |
fetch = get |
Represents a CloudFiles storage object.
def __init__ | ( | self, | |
client, | |||
container, | |||
name = None , |
|||
total_bytes = None , |
|||
content_type = None , |
|||
last_modified = None , |
|||
etag = None , |
|||
attdict = None |
|||
) |
The object can either be initialized with individual params, or by passing the dict that is returned by swiftclient.
def __repr__ | ( | self | ) |
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 delete | ( | self | ) |
Deletes the object from storage.
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 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 this object's metadata.
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 purge | ( | self, | |
email_addresses = [] |
|||
) |
Purges the object from the CDN network, sending an optional email confirmation.
def remove_metadata_key | ( | self, | |
key | |||
) |
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 |
|||
) |
Sets this object's metadata, optionally clearing existing metadata.