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

Procedural File: cloudfiles.php

Source Location: /cloudfiles.php



Classes:

CF_Authentication
Class for handling Cloud Files Authentication, call it's authenticate() method to obtain authorized service urls and an authentication token.
CF_Connection
Class for establishing connections to the Cloud Files storage system.
CF_Container
Container operations
CF_Object
Object operations


Page Details:

This is the PHP Cloud Files API.

  1.    # Authenticate to Cloud Files.  The default is to automatically try
  2.    # to re-authenticate if an authentication token expires.
  3.    #
  4.    # NOTE: Some versions of cURL include an outdated certificate authority (CA)
  5.    #       file.  This API ships with a newer version obtained directly from
  6.    #       cURL's web site (http://curl.haxx.se).  To use the newer CA bundle,
  7.    #       call the CF_Authentication instance's 'ssl_use_cabundle()' method.
  8.    #
  9.    $auth new CF_Authentication($username$api_key);
  10.    # $auth->ssl_use_cabundle();  # bypass cURL's old CA bundle
  11.    $auth->authenticate();
  12.  
  13.    # Establish a connection to the storage system
  14.    #
  15.    # NOTE: Some versions of cURL include an outdated certificate authority (CA)
  16.    #       file.  This API ships with a newer version obtained directly from
  17.    #       cURL's web site (http://curl.haxx.se).  To use the newer CA bundle,
  18.    #       call the CF_Connection instance's 'ssl_use_cabundle()' method.
  19.    #
  20.    $conn new CF_Connection($auth);
  21.    # $conn->ssl_use_cabundle();  # bypass cURL's old CA bundle
  22.  
  23.    # Create a remote Container and storage Object
  24.    #
  25.    $images $conn->create_container("photos");
  26.    $bday $images->create_object("first_birthday.jpg");
  27.  
  28.    # Upload content from a local file by streaming it.  Note that we use
  29.    # a "float" for the file size to overcome PHP's 32-bit integer limit for
  30.    # very large files.
  31.    #
  32.    $fname "/home/user/photos/birthdays/birthday1.jpg";  # filename to upload
  33.    $size = (float) sprintf("%u"filesize($fname));
  34.    $fp open($fname"r");
  35.    $bday->write($fp$size);
  36.  
  37.    # Or... use a convenience function instead
  38.    #
  39.    $bday->load_from_filename("/home/user/photos/birthdays/birthday1.jpg");
  40.  
  41.    # Now, publish the "photos" container to serve the images by CDN.
  42.    # Use the "$uri" value to put in your web pages or send the link in an
  43.    # email message, etc.
  44.    #
  45.    $uri $images->make_public();
  46.  
  47.    # Or... print out the Object's public URI
  48.    #
  49.    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.




Tags:

author:  Eric "EJ" Johnson <ej@racklabs.com>
copyright:  Copyright (c) 2008, Rackspace US, Inc.


Includes:

require("cloudfiles_http.php") [line 75]
require_once("cloudfiles_exceptions.php") [line 74]





DEFAULT_CF_API_VERSION [line 76]

DEFAULT_CF_API_VERSION = 1

[ Top ]



MAX_CONTAINER_NAME_LEN [line 77]

MAX_CONTAINER_NAME_LEN = 256

[ Top ]



MAX_OBJECT_NAME_LEN [line 78]

MAX_OBJECT_NAME_LEN = 1024

[ Top ]



MAX_OBJECT_SIZE [line 79]

MAX_OBJECT_SIZE = 5*1024*1024*1024+1

[ Top ]



UK_AUTHURL [line 81]

UK_AUTHURL = "https://lon.auth.api.rackspacecloud.com"

[ Top ]



US_AUTHURL [line 80]

US_AUTHURL = "https://auth.api.rackspacecloud.com"

[ Top ]




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