# Authenticate to Cloud Files. The default is to automatically try
# to re-authenticate if an authentication token expires.
#
# NOTE: Some versions of cURL include an outdated certificate authority (CA)
# file. This API ships with a newer version obtained directly from
# cURL's web site (http://curl.haxx.se). To use the newer CA bundle,
# call the CF_Authentication instance's 'ssl_use_cabundle()' method.
#
# $auth->ssl_use_cabundle(); # bypass cURL's old CA bundle
$auth->authenticate();
# Establish a connection to the storage system
#
# NOTE: Some versions of cURL include an outdated certificate authority (CA)
# file. This API ships with a newer version obtained directly from
# cURL's web site (http://curl.haxx.se). To use the newer CA bundle,
# call the CF_Connection instance's 'ssl_use_cabundle()' method.
#
# $conn->ssl_use_cabundle(); # bypass cURL's old CA bundle
# Create a remote Container and storage Object
#
$images = $conn->create_container("photos");
$bday = $images->create_object("first_birthday.jpg");
# Upload content from a local file by streaming it. Note that we use
# a "float" for the file size to overcome PHP's 32-bit integer limit for
# very large files.
#
$fname = "/home/user/photos/birthdays/birthday1.jpg"; # filename to upload
$fp = open($fname, "r");
$bday->write($fp, $size);
# Or... use a convenience function instead
#
$bday->load_from_filename("/home/user/photos/birthdays/birthday1.jpg");
# Now, publish the "photos" container to serve the images by CDN.
# Use the "$uri" value to put in your web pages or send the link in an
# email message, etc.
#
$uri = $images->make_public();
# Or... print out the Object's public URI
#
print $bday->public_uri();
See the included tests directory for additional sample code.
Requres PHP 5.x (for Exceptions and OO syntax) and PHP's cURL module.
It uses the supporting "cloudfiles_http.php" module for HTTP(s) support and allows for connection re-use and streaming of content into/out of Cloud Files via PHP's cURL module.
See COPYING for license information.