Rackspace Cloudfiles PHP API Cookbook

Posted on 03/19/2014 at 10:33 pm by Kevin Wentworth
Viewed 9,885 times | 0 comments

I'm working on the latest API of the Rackspace Cloudfiles API (php-opencloud).  I've had a bear of a time figuring everything out.  I think I was making it too complicated (plus I was starting on an older version of the PHP SDK... but that's another story).  Now that I'm figuring out the API, the Rackspace PHP developers have done a really good job of making the functionality work with minimal coding.

Basic Rackspace Cloudfiles Container Operations

Get a reference to a Container

  1. $Container = $service->getContainer($containerName);

Get metadata (from initial container instantiation; can refresh metadata using retrieveMetadata())

  1. $metadata = $Container->getMetadata();
  2. $origin = $metadata->getProperty('Access-Control-Allow-Origin');

Save a meta value (or update the value if it already exists)
Note: you don't have to specify X-Container-Meta-, the system automatically does this for you (using stockHeaders())

  1. $meta = array('Access-Control-Allow-Origin' => $myServerUrl);
  2. $Container->saveMetadata($meta);

Remove a meta value (or unset a meta value) on a container

  1. $Container->unsetMetadataItem('any-meta-key-value');

Refresh container meta data (Retrieve a fresh copy of metadata from API)

  1. $metadata = $Container->retrieveMetadata();
  2. $value = $metadata->getProperty('any-meta-key-value');

NOTE: don't use appendMetadata() function.  This doesn't do anything but update the local metadata store (from what I can tell)

Bookmark and Share

Tags for Rackspace Cloudfiles PHP API Cookbook

Cakephp | Cloudfiles | Web Programming | Usage

Comments for this Posting

No comments. Be the first to post a reply.

Sorry, comments are closed for this posting.

Please Email Kevin if you have any questions. Thanks!

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design