ucloud storage php doc
 All Data Structures Namespaces Files Functions Variables
Public Member Functions | Data Fields
CF_Connection Class Reference

Public Member Functions

 __construct ($cfs_auth)
 
 setDebug ($bool)
 
 close ()
 
 get_info ()
 
 create_container ($container_name=NULL)
 
 delete_container ($container=NULL)
 
 get_container ($container_name=NULL)
 
 get_containers ($limit=0, $marker=NULL)
 
 list_containers ($limit=0, $marker=NULL)
 
 list_containers_info ($limit=0, $marker=NULL)
 
 set_read_progress_function ($func_name)
 
 set_write_progress_function ($func_name)
 
 ssl_use_cabundle ($path=NULL)
 

Data Fields

 $dbug
 
 $cfs_http
 
 $cfs_auth
 

Detailed Description

Definition at line 320 of file cloudfiles-kt.php.

Constructor & Destructor Documentation

__construct (   $cfs_auth)

Pass in a previously authenticated CF_Authentication instance.

Example: Create the authentication instance

$auth = new CF_Authentication("username", "api_key");

Perform authentication request

$auth->authenticate();

Create a connection to the storage system(s) and pass in the validated CF_Authentication instance.

$conn = new CF_Connection($auth);

Parameters
obj$cfs_authpreviously authenticated CF_Authentication instance
Exceptions
AuthenticationExceptionnot authenticated

Definition at line 348 of file cloudfiles-kt.php.

Member Function Documentation

close ( )

Close a connection

Example:

$conn->close();

Will close all current cUrl active connections.

Definition at line 385 of file cloudfiles-kt.php.

create_container (   $container_name = NULL)

Create a Container

Given a Container name, return a Container instance, creating a new remote Container if it does not exit.

Example: ... authentication code excluded (see previous examples) ...

$conn = new CF_Connection($auth);

$images = $conn->create_container("my photos");

Parameters
string$container_namecontainer name
Returns
CF_Container
Exceptions
SyntaxExceptioninvalid name
InvalidResponseExceptionunexpected response

Definition at line 444 of file cloudfiles-kt.php.

delete_container (   $container = NULL)

Delete a Container

Given either a Container instance or name, remove the remote Container. The Container must be empty prior to removing it.

Example: ... authentication code excluded (see previous examples) ...

$conn = new CF_Connection($auth);

$conn->delete_container("my photos");

Parameters
string | obj$containercontainer name or instance
Returns
boolean True if successfully deleted
Exceptions
SyntaxExceptionmissing proper argument
InvalidResponseExceptioninvalid response
NonEmptyContainerExceptioncontainer not empty
NoSuchContainerExceptionremote container does not exist

Definition at line 501 of file cloudfiles-kt.php.

get_container (   $container_name = NULL)

Return a Container instance

For the given name, return a Container instance if the remote Container exists, otherwise throw a Not Found exception.

Example: ... authentication code excluded (see previous examples) ...

$conn = new CF_Connection($auth);

$images = $conn->get_container("my photos"); print "Number of Objects: " . $images->object_count . "\n"; print "Bytes stored in container: " . $images->bytes_used . "\n";

Parameters
string$container_namename of the remote Container
Returns
container CF_Container instance
Exceptions
NoSuchContainerExceptionthrown if no remote Container
InvalidResponseExceptionunexpected response

Definition at line 563 of file cloudfiles-kt.php.

get_containers (   $limit = 0,
  $marker = NULL 
)

Return array of Container instances

Return an array of CF_Container instances on the account. The instances will be fully populated with Container attributes (bytes stored and Object count)

Example: ... authentication code excluded (see previous examples) ...

$conn = new CF_Connection($auth);

$clist = $conn->get_containers(); foreach ($clist as $cont) { print "Container name: " . $cont->name . "\n"; print "Number of Objects: " . $cont->object_count . "\n"; print "Bytes stored in container: " . $cont->bytes_used . "\n"; }

Returns
array An array of CF_Container instances
Exceptions
InvalidResponseExceptionunexpected response

Definition at line 605 of file cloudfiles-kt.php.

get_info ( )

Cloud Files account information

Return an array of two floats (since PHP only supports 32-bit integers); number of containers on the account and total bytes used for the account.

Example: ... authentication code excluded (see previous examples) ...

$conn = new CF_Connection($auth);

list($quantity, $bytes) = $conn->get_info(); print "Number of containers: " . $quantity . "\n"; print "Bytes stored in container: " . $bytes . "\n";

Returns
array (number of containers, total bytes stored)
Exceptions
InvalidResponseExceptionunexpected response

Definition at line 410 of file cloudfiles-kt.php.

list_containers (   $limit = 0,
  $marker = NULL 
)

Return list of remote Containers

Return an array of strings containing the names of all remote Containers.

Example: ... authentication code excluded (see previous examples) ...

$conn = new CF_Connection($auth);

$container_list = $conn->list_containers(); print_r($container_list); Array ( [0] => "my photos", [1] => "my docs" )

Parameters
integer$limitrestrict results to $limit Containers
string$markerreturn results greater than $marker
Returns
array list of remote Containers
Exceptions
InvalidResponseExceptionunexpected response

Definition at line 649 of file cloudfiles-kt.php.

list_containers_info (   $limit = 0,
  $marker = NULL 
)

Return array of information about remote Containers

Return a nested array structure of Container info.

Example: ... authentication code excluded (see previous examples) ...

$container_info = $conn->list_containers_info(); print_r($container_info); Array ( ["my photos"] => Array ( ["bytes"] => 78, ["count"] => 2 ) ["docs"] => Array ( ["bytes"] => 37323, ["count"] => 12 ) )

Parameters
integer$limitrestrict results to $limit Containers
string$markerreturn results greater than $marker
Returns
array nested array structure of Container info
Exceptions
InvalidResponseExceptionunexpected response

Definition at line 697 of file cloudfiles-kt.php.

set_read_progress_function (   $func_name)

Set a user-supplied callback function to report download progress

The callback function is used to report incremental progress of a data download functions (e.g. $container->list_objects(), $obj->read(), etc). The specified function will be periodically called with the number of bytes transferred until the entire download is complete. This callback function can be useful for implementing "progress bars" for large downloads.

The specified callback function should take a single integer parameter.

function read_callback($bytes_transferred) { print ">> downloaded " . $bytes_transferred . " bytes.\n";

... do other things ...

return; }

$conn = new CF_Connection($auth_obj); $conn->set_read_progress_function("read_callback"); print_r($conn->list_containers());

output would look like this:

downloaded 10 bytes. downloaded 11 bytes.

Array ( [0] => fuzzy.txt [1] => space name )

Parameters
string$func_namethe name of the user callback function

Definition at line 747 of file cloudfiles-kt.php.

set_write_progress_function (   $func_name)

Set a user-supplied callback function to report upload progress

The callback function is used to report incremental progress of a data upload functions (e.g. $obj->write() call). The specified function will be periodically called with the number of bytes transferred until the entire upload is complete. This callback function can be useful for implementing "progress bars" for large uploads/downloads.

The specified callback function should take a single integer parameter.

function write_callback($bytes_transferred) { print ">> uploaded " . $bytes_transferred . " bytes.\n";

... do other things ...

return; }

$conn = new CF_Connection($auth_obj); $conn->set_write_progress_function("write_callback"); $container = $conn->create_container("stuff"); $obj = $container->create_object("foo"); $obj->write("The callback function will be called during upload.");

output would look like this:

uploaded 51 bytes.

Parameters
string$func_namethe name of the user callback function

Definition at line 783 of file cloudfiles-kt.php.

setDebug (   $bool)

Toggle debugging of instance and back-end HTTP module

Parameters
boolean$boolenable/disable cURL debugging

Definition at line 366 of file cloudfiles-kt.php.

ssl_use_cabundle (   $path = NULL)

Use the Certificate Authority bundle included with this API

Most versions of PHP with cURL support include an outdated Certificate Authority (CA) bundle (the file that lists all valid certificate signing authorities). The SSL certificates used by the Cloud Files storage system are perfectly valid but have been created/signed by a CA not listed in these outdated cURL distributions.

As a work-around, we've included an updated CA bundle obtained directly from cURL's web site (http://curl.haxx.se). You can direct the API to use this CA bundle by calling this method prior to making any remote calls. The best place to use this method is right after the CF_Authentication instance has been instantiated.

You can specify your own CA bundle by passing in the full pathname to the bundle. You can use the included CA bundle by leaving the argument blank.

Parameters
string$pathSpecify path to CA bundle (default to included)

Definition at line 809 of file cloudfiles-kt.php.

Field Documentation

$cfs_auth

Definition at line 324 of file cloudfiles-kt.php.

$cfs_http

Definition at line 323 of file cloudfiles-kt.php.

$dbug

Definition at line 322 of file cloudfiles-kt.php.


The documentation for this class was generated from the following file: