php-cloudfiles
[ class tree: php-cloudfiles ] [ index: php-cloudfiles ] [ all elements ]

Class: CF_Container

Source Location: /cloudfiles.php

Class Overview


Container operations


Variables

Methods



Class Details

[line 917]
Container operations

Containers are storage compartments where you put your data (objects). A container is similar to a directory or folder on a conventional filesystem with the exception that they exist in a flat namespace, you can not create containers inside of containers.

You also have the option of marking a Container as "public" so that the Objects stored in the Container are publicly available via the CDN.




[ Top ]


Class Variables

$bytes_used =

[line 923]



Tags:

access:  public

Type:   mixed


[ Top ]

$cdn_acl_referrer =

[line 932]



Tags:

access:  public

Type:   mixed


[ Top ]

$cdn_acl_user_agent =

[line 931]



Tags:

access:  public

Type:   mixed


[ Top ]

$cdn_enabled =

[line 925]



Tags:

access:  public

Type:   mixed


[ Top ]

$cdn_log_retention =

[line 930]



Tags:

access:  public

Type:   mixed


[ Top ]

$cdn_ssl_uri =

[line 927]



Tags:

access:  public

Type:   mixed


[ Top ]

$cdn_streaming_uri =

[line 926]



Tags:

access:  public

Type:   mixed


[ Top ]

$cdn_ttl =

[line 929]



Tags:

access:  public

Type:   mixed


[ Top ]

$cdn_uri =

[line 928]



Tags:

access:  public

Type:   mixed


[ Top ]

$cfs_auth =

[line 919]



Tags:

access:  public

Type:   mixed


[ Top ]

$cfs_http =

[line 920]



Tags:

access:  public

Type:   mixed


[ Top ]

$name =

[line 921]



Tags:

access:  public

Type:   mixed


[ Top ]

$object_count =

[line 922]



Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 946]

CF_Container __construct( &$cfs_auth, &$cfs_http, string $name, [int $count = 0], [int $bytes = 0], [ $docdn = True], obj $cfs_auth, obj $cfs_http)

Class constructor

Constructor for Container




Tags:

throws:  SyntaxException invalid Container name


Parameters:

obj   $cfs_auth   CF_Authentication instance
obj   $cfs_http   HTTP connection manager
string   $name   name of Container
int   $count   number of Objects stored in this Container
int   $bytes   number of bytes stored in this Container
   &$cfs_auth  
   &$cfs_http  
   $docdn  

[ Top ]

method acl_referrer [line 1167]

boolean acl_referrer( [ $cdn_acl_referrer = ""])

Enable ACL restriction by referer for this container.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $public_container $conn->get_container("public");
  6.  
  7.  # Enable Referrer
  8.  $public_container->acl_referrer("http://www.example.com/gallery.php");




Tags:

return:  True if successful
throws:  CDNNotEnabledException CDN functionality not returned during auth
throws:  AuthenticationException if auth token is not valid/expired
throws:  InvalidResponseException unexpected response


Parameters:

   $cdn_acl_referrer  

[ Top ]

method acl_user_agent [line 1127]

boolean acl_user_agent( [ $cdn_acl_user_agent = ""])

Enable ACL restriction by User Agent for this container.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $public_container $conn->get_container("public");
  6.  
  7.  # Enable ACL by Referrer
  8.  $public_container->acl_referrer("Mozilla");




Tags:

return:  True if successful
throws:  CDNNotEnabledException CDN functionality not returned during auth
throws:  AuthenticationException if auth token is not valid/expired
throws:  InvalidResponseException unexpected response


Parameters:

   $cdn_acl_user_agent  

[ Top ]

method copy_object_from [line 1601]

boolean copy_object_from( obj $obj, obj $container_source, [string $dest_obj_name = NULL], [array $metadata = NULL], [array $headers = NULL])

Copy a remote storage Object from a source Container

Given an Object instance or name and a source Container instance or name, copy copies the remote Object and all associated metadata.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $images $conn->get_container("my photos");
  6.  
  7.  # Copy specific object
  8.  #
  9.  $images->copy_object_from("disco_dancing.jpg","container_source");




Tags:

return:  true if successfully copied
throws:  SyntaxException invalid Object/Container name
throws:  NoSuchObjectException remote Object does not exist
throws:  InvalidResponseException unexpected response


Parameters:

obj   $obj   name or instance of Object to copy
obj   $container_source   name or instance of source Container
string   $dest_obj_name   name of target object (optional - uses source name if omitted)
array   $metadata   metadata array for new object (optional)
array   $headers   header fields array for the new object (optional)

[ Top ]

method copy_object_to [line 1527]

boolean copy_object_to( obj $obj, obj $container_target, [string $dest_obj_name = NULL], [array $metadata = NULL], [array $headers = NULL])

Copy a remote storage Object to a target Container

Given an Object instance or name and a target Container instance or name, copy copies the remote Object and all associated metadata.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $images $conn->get_container("my photos");
  6.  
  7.  # Copy specific object
  8.  #
  9.  $images->copy_object_to("disco_dancing.jpg","container_target");




Tags:

return:  true if successfully copied
throws:  SyntaxException invalid Object/Container name
throws:  NoSuchObjectException remote Object does not exist
throws:  InvalidResponseException unexpected response


Parameters:

obj   $obj   name or instance of Object to copy
obj   $container_target   name or instance of target Container
string   $dest_obj_name   name of target object (optional - uses source name if omitted)
array   $metadata   metadata array for new object (optional)
array   $headers   header fields array for the new object (optional)

[ Top ]

method create_object [line 1337]

obj create_object( [string $obj_name = NULL])

Create a new remote storage Object

Return a new Object instance. If the remote storage Object exists, the instance's attributes are populated.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $public_container $conn->get_container("public");
  6.  
  7.  # This creates a local instance of a storage object but only creates
  8.  # it in the storage system when the object's write() method is called.
  9.  #
  10.  $pic $public_container->create_object("baby.jpg");




Tags:

return:  CF_Object instance


Parameters:

string   $obj_name   name of storage Object

[ Top ]

method create_paths [line 1813]

void create_paths( $path_name)

Helper function to create "path" elements for a given Object name

Given an Object whos name contains '/' path separators, this function will create the "directory marker" Objects of one byte with the Content-Type of "application/directory".

It assumes the last element of the full path is the "real" Object and does NOT create a remote storage Object for that last element.




Parameters:

   $path_name  

[ Top ]

method delete_object [line 1753]

boolean delete_object( obj $obj, [obj $container = NULL])

Delete a remote storage Object

Given an Object instance or name, permanently remove the remote Object and all associated metadata.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $images $conn->get_container("my photos");
  6.  
  7.  # Delete specific object
  8.  #
  9.  $images->delete_object("disco_dancing.jpg");




Tags:

return:  True if successfully removed
throws:  SyntaxException invalid Object name
throws:  NoSuchObjectException remote Object does not exist
throws:  InvalidResponseException unexpected response


Parameters:

obj   $obj   name or instance of Object to delete
obj   $container   name or instance of Container in which the object resides (optional)

[ Top ]

method get_object [line 1366]

obj get_object( [string $obj_name = NULL])

Return an Object instance for the remote storage Object

Given a name, return a Object instance representing the remote storage object.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $public_container $conn->get_container("public");
  6.  
  7.  # This call only fetches header information and not the content of
  8.  # the storage object.  Use the Object's read() or stream() methods
  9.  # to obtain the object's data.
  10.  #
  11.  $pic $public_container->get_object("baby.jpg");




Tags:

return:  CF_Object instance


Parameters:

string   $obj_name   name of storage Object

[ Top ]

method get_objects [line 1474]

array get_objects( [int $limit = 0], [int $marker = NULL], [string $prefix = NULL], [string $path = NULL])

Return an array of Objects

Return an array of Object instances in this Container.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $images $conn->get_container("my photos");
  4.  
  5.  # Grab the list of all storage objects
  6.  #
  7.  $all_objects $images->get_objects();
  8.  
  9.  # Grab subsets of all storage objects
  10.  #
  11.  $first_ten $images->get_objects(10);
  12.  
  13.  # Note the use of the previous result's last object name being
  14.  # used as the 'marker' parameter to fetch the next 10 objects
  15.  #
  16.  $next_ten $images->list_objects(10$first_ten[count($first_ten)-1]);
  17.  
  18.  # Grab images starting with "birthday_party" and default limit/marker
  19.  # to match all photos with that prefix
  20.  #
  21.  $prefixed $images->get_objects(0NULL"birthday");
  22.  
  23.  # Assuming you have created the appropriate directory marker Objects,
  24.  # you can traverse your pseudo-hierarchical containers
  25.  # with the "path" argument.
  26.  #
  27.  $animals $images->get_objects(0,NULL,NULL,"pictures/animals");
  28.  $dogs $images->get_objects(0,NULL,NULL,"pictures/animals/dogs");




Tags:

return:  array of strings
throws:  InvalidResponseException unexpected response


Parameters:

int   $limit   optional only return $limit names
int   $marker   optional subset of names starting at $marker
string   $prefix   optional Objects whose names begin with $prefix
string   $path   optional only return results under "pathname"

[ Top ]

method is_public [line 1309]

boolean is_public( )

Check if this Container is being publicly served via CDN

Use this method to determine if the Container's content is currently available through the CDN.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $public_container $conn->get_container("public");
  6.  
  7.  # Display CDN accessability
  8.  #
  9.  $public_container->is_public(? print "Yes" : print "No";




Tags:

return:  True if enabled, False otherwise


[ Top ]

method list_objects [line 1415]

array list_objects( [int $limit = 0], [int $marker = NULL], [string $prefix = NULL], [string $path = NULL])

Return a list of Objects

Return an array of strings listing the Object names in this Container.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $images $conn->get_container("my photos");
  4.  
  5.  # Grab the list of all storage objects
  6.  #
  7.  $all_objects $images->list_objects();
  8.  
  9.  # Grab subsets of all storage objects
  10.  #
  11.  $first_ten $images->list_objects(10);
  12.  
  13.  # Note the use of the previous result's last object name being
  14.  # used as the 'marker' parameter to fetch the next 10 objects
  15.  #
  16.  $next_ten $images->list_objects(10$first_ten[count($first_ten)-1]);
  17.  
  18.  # Grab images starting with "birthday_party" and default limit/marker
  19.  # to match all photos with that prefix
  20.  #
  21.  $prefixed $images->list_objects(0NULL"birthday");
  22.  
  23.  # Assuming you have created the appropriate directory marker Objects,
  24.  # you can traverse your pseudo-hierarchical containers
  25.  # with the "path" argument.
  26.  #
  27.  $animals $images->list_objects(0,NULL,NULL,"pictures/animals");
  28.  $dogs $images->list_objects(0,NULL,NULL,"pictures/animals/dogs");




Tags:

return:  array of strings
throws:  InvalidResponseException unexpected response


Parameters:

int   $limit   optional only return $limit names
int   $marker   optional subset of names starting at $marker
string   $prefix   optional Objects whose names begin with $prefix
string   $path   optional only return results under "pathname"

[ Top ]

method log_retention [line 1213]

boolean log_retention( [ $cdn_log_retention = False])

Enable log retention for this CDN container.

Enable CDN log retention on the container. If enabled logs will be periodically (at unpredictable intervals) compressed and uploaded to a ".CDN_ACCESS_LOGS" container in the form of "container_name.YYYYMMDDHH-XXXX.gz". Requires CDN be enabled on the account.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $public_container $conn->get_container("public");
  6.  
  7.  # Enable logs retention.
  8.  $public_container->log_retention(True);




Tags:

return:  True if successful
throws:  CDNNotEnabledException CDN functionality not returned during auth
throws:  AuthenticationException if auth token is not valid/expired
throws:  InvalidResponseException unexpected response


Parameters:

   $cdn_log_retention  

[ Top ]

method make_private [line 1263]

boolean make_private( )

Disable the CDN sharing for this container

Use this method to disallow distribution into the CDN of this Container's content.

NOTE: Any content already cached in the CDN will continue to be served from its cache until the TTL expiration transpires. The default TTL is typically one day, so "privatizing" the Container will take up to 24 hours before the content is purged from the CDN cache.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $public_container $conn->get_container("public");
  6.  
  7.  # Disable CDN accessability
  8.  # ... still cached up to a month based on previous example
  9.  #
  10.  $public_container->make_private();




Tags:

return:  True if successful
throws:  CDNNotEnabledException CDN functionality not returned during auth
throws:  AuthenticationException if auth token is not valid/expired
throws:  InvalidResponseException unexpected response


[ Top ]

method make_public [line 1032]

string make_public( [int $ttl = 86400])

Enable Container content to be served via CDN or modify CDN attributes

Either enable this Container's content to be served via CDN or adjust its CDN attributes. This Container will always return the same CDN-enabled URI each time it is toggled public/private/public.

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $public_container $conn->create_container("public");
  6.  
  7.  # CDN-enable the container and set it's TTL for a month
  8.  #
  9.  $public_container->make_public(86400/2)# 12 hours (86400 seconds/day)




Tags:

return:  the CDN enabled Container's URI
throws:  CDNNotEnabledException CDN functionality not returned during auth
throws:  AuthenticationException if auth token is not valid/expired
throws:  InvalidResponseException unexpected response


Parameters:

int   $ttl   the time in seconds content will be cached in the CDN

[ Top ]

method move_object_from [line 1716]

boolean move_object_from( obj $obj, obj $container_source, [string $dest_obj_name = NULL], [array $metadata = NULL], [array $headers = NULL])

Move a remote storage Object from a source Container

Given an Object instance or name and a source Container instance or name, move copies the remote Object and all associated metadata and deletes the source Object afterwards

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $images $conn->get_container("my photos");
  6.  
  7.  # Move specific object
  8.  #
  9.  $images->move_object_from("disco_dancing.jpg","container_target");




Tags:

return:  true if successfully moved
throws:  SyntaxException invalid Object/Container name
throws:  NoSuchObjectException remote Object does not exist
throws:  InvalidResponseException unexpected response


Parameters:

obj   $obj   name or instance of Object to move
obj   $container_source   name or instance of target Container
string   $dest_obj_name   name of target object (optional - uses source name if omitted)
array   $metadata   metadata array for new object (optional)
array   $headers   header fields array for the new object (optional)

[ Top ]

method move_object_to [line 1676]

boolean move_object_to( obj $obj, obj $container_target, [string $dest_obj_name = NULL], [array $metadata = NULL], [array $headers = NULL])

Move a remote storage Object to a target Container

Given an Object instance or name and a target Container instance or name, move copies the remote Object and all associated metadata and deletes the source Object afterwards

Example:

  1.  # ... authentication code excluded (see previous examples) ...
  2.  #
  3.  $conn new CF_Authentication($auth);
  4.  
  5.  $images $conn->get_container("my photos");
  6.  
  7.  # Move specific object
  8.  #
  9.  $images->move_object_to("disco_dancing.jpg","container_target");




Tags:

return:  true if successfully moved
throws:  SyntaxException invalid Object/Container name
throws:  NoSuchObjectException remote Object does not exist
throws:  InvalidResponseException unexpected response


Parameters:

obj   $obj   name or instance of Object to move
obj   $container_target   name or instance of target Container
string   $dest_obj_name   name of target object (optional - uses source name if omitted)
array   $metadata   metadata array for new object (optional)
array   $headers   header fields array for the new object (optional)

[ Top ]

method purge_from_cdn [line 1093]

boolean purge_from_cdn( [ $email = null])

Purge Containers objects from CDN Cache.

Example:




Tags:

return:  True if successful
throws:  CDNNotEnabledException if CDN Is not enabled on this connection
throws:  InvalidResponseException if the response expected is not returned


Parameters:

   $email  

[ Top ]

method __toString [line 982]

string __toString( )

String representation of Container

Pretty print the Container instance.




Tags:

return:  Container details


[ Top ]


Documentation generated on Wed, 07 Sep 2011 15:19:57 -0500 by phpDocumentor 1.4.3